You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by pa...@apache.org on 2016/12/09 16:28:32 UTC

[1/7] zest-java git commit: entitystores: replace usage of core/io with streams

Repository: zest-java
Updated Branches:
  refs/heads/develop 8854b1306 -> 0b4cca068


http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
index a52b526..fa66da2 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
@@ -34,8 +34,13 @@ import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Spliterator;
+import java.util.Spliterators;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
 import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.common.QualifiedName;
 import org.apache.zest.api.entity.EntityDescriptor;
@@ -57,11 +62,6 @@ import org.apache.zest.entitystore.sql.internal.DatabaseSQLService;
 import org.apache.zest.entitystore.sql.internal.DatabaseSQLService.EntityValueResult;
 import org.apache.zest.entitystore.sql.internal.SQLEntityState;
 import org.apache.zest.entitystore.sql.internal.SQLEntityState.DefaultSQLEntityState;
-import org.apache.zest.functional.Visitor;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
 import org.apache.zest.library.sql.common.SQLUtil;
 import org.apache.zest.spi.ZestSPI;
 import org.apache.zest.spi.entity.EntityState;
@@ -272,7 +272,8 @@ public class SQLEntityStoreMixin
                                        EntityDescriptor entityDescriptor
     )
     {
-        return new DefaultSQLEntityState( new DefaultEntityState( unitOfWork.currentTime(), entityRef, entityDescriptor ) );
+        return new DefaultSQLEntityState(
+            new DefaultEntityState( unitOfWork.currentTime(), entityRef, entityDescriptor ) );
     }
 
     @Override
@@ -282,77 +283,56 @@ public class SQLEntityStoreMixin
     }
 
     @Override
-    public Input<EntityState, EntityStoreException> entityStates( final ModuleDescriptor module )
+    public Stream<EntityState> entityStates( final ModuleDescriptor module )
     {
-        return new Input<EntityState, EntityStoreException>()
+        try
         {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super EntityState, ReceiverThrowableType> output )
-                throws EntityStoreException, ReceiverThrowableType
-            {
-                output.receiveFrom( new Sender<EntityState, EntityStoreException>()
+            Connection connection = database.getConnection();
+            PreparedStatement ps = database.prepareGetAllEntitiesStatement( connection );
+            database.populateGetAllEntitiesStatement( ps );
+            ResultSet rs = ps.executeQuery();
+            return StreamSupport.stream(
+                new Spliterators.AbstractSpliterator<EntityState>( Long.MAX_VALUE, Spliterator.ORDERED )
                 {
                     @Override
-                    public <RecThrowableType extends Throwable> void sendTo( final Receiver<? super EntityState, RecThrowableType> receiver )
-                        throws RecThrowableType, EntityStoreException
+                    public boolean tryAdvance( final Consumer<? super EntityState> action )
                     {
-                        queryAllEntities( module, visited -> {
-                            try
-                            {
-                                receiver.receive( visited );
-                            }
-                            catch( Throwable receiverThrowableType )
-                            {
-                                throw new SQLException( receiverThrowableType );
-                            }
+                        try
+                        {
+                            if( !rs.next() ) { return false; }
+                            EntityState entityState = readEntityState( module,
+                                                                       database.getEntityValue( rs ).getReader() );
+                            action.accept( entityState );
                             return true;
-                        } );
+                        }
+                        catch( SQLException ex )
+                        {
+                            SQLUtil.closeQuietly( rs, ex );
+                            SQLUtil.closeQuietly( ps, ex );
+                            SQLUtil.closeQuietly( connection, ex );
+                            throw new EntityStoreException( ex );
+                        }
                     }
-                } );
-            }
-        };
-    }
-
-    private void queryAllEntities( ModuleDescriptor module, EntityStatesVisitor entityStatesVisitor )
-    {
-        Connection connection = null;
-        PreparedStatement ps = null;
-        ResultSet rs = null;
-        try
-        {
-            connection = database.getConnection();
-            ps = database.prepareGetAllEntitiesStatement( connection );
-            database.populateGetAllEntitiesStatement( ps );
-            rs = ps.executeQuery();
-            while( rs.next() )
-            {
-                DefaultEntityState entityState = readEntityState( module, database.getEntityValue( rs ).getReader() );
-                if( !entityStatesVisitor.visit( entityState ) )
+                },
+                false
+            ).onClose(
+                () ->
                 {
-                    return;
+                    SQLUtil.closeQuietly( rs );
+                    SQLUtil.closeQuietly( ps );
+                    SQLUtil.closeQuietly( connection );
                 }
-            }
+            );
         }
         catch( SQLException ex )
         {
             throw new EntityStoreException( ex );
         }
-        finally
-        {
-            SQLUtil.closeQuietly( rs );
-            SQLUtil.closeQuietly( ps );
-            SQLUtil.closeQuietly( connection );
-        }
-    }
-
-    private interface EntityStatesVisitor
-        extends Visitor<EntityState, SQLException>
-    {
     }
 
     protected Identity newUnitOfWorkId()
     {
-        return identityGenerator.generate(EntityStore.class);
+        return identityGenerator.generate( EntityStore.class );
     }
 
     protected DefaultEntityState readEntityState( ModuleDescriptor module, Reader entityState )
@@ -364,7 +344,7 @@ public class SQLEntityStoreMixin
             final EntityStatus[] status = { EntityStatus.LOADED };
 
             String version = jsonObject.getString( JSONKeys.VERSION );
-            Instant modified = Instant.ofEpochMilli(jsonObject.getLong( JSONKeys.MODIFIED ));
+            Instant modified = Instant.ofEpochMilli( jsonObject.getLong( JSONKeys.MODIFIED ) );
             String identity = jsonObject.getString( JSONKeys.IDENTITY );
 
             // Check if version is correct
@@ -398,102 +378,117 @@ public class SQLEntityStoreMixin
 
             Map<QualifiedName, Object> properties = new HashMap<>();
             JSONObject props = jsonObject.getJSONObject( JSONKeys.PROPERTIES );
-            entityDescriptor.state().properties().forEach( propertyDescriptor -> {
-                Object jsonValue;
-                try
+            entityDescriptor.state().properties().forEach(
+                propertyDescriptor ->
                 {
-                    jsonValue = props.get( propertyDescriptor.qualifiedName().name() );
-                    if( JSONObject.NULL.equals( jsonValue ) )
+                    Object jsonValue;
+                    try
                     {
-                        properties.put( propertyDescriptor.qualifiedName(), null );
+                        jsonValue = props.get(
+                            propertyDescriptor.qualifiedName().name() );
+                        if( JSONObject.NULL.equals( jsonValue ) )
+                        {
+                            properties.put( propertyDescriptor.qualifiedName(), null );
+                        }
+                        else
+                        {
+                            Object value = valueSerialization.deserialize( module,
+                                                                           propertyDescriptor.valueType(),
+                                                                           jsonValue.toString() );
+                            properties.put( propertyDescriptor.qualifiedName(), value );
+                        }
                     }
-                    else
+                    catch( JSONException e )
                     {
-                        Object value = valueSerialization.deserialize( module, propertyDescriptor.valueType(), jsonValue
-                            .toString() );
-                        properties.put( propertyDescriptor.qualifiedName(), value );
+                        // Value not found, default it
+                        Object initialValue = propertyDescriptor.initialValue( module );
+                        properties.put( propertyDescriptor.qualifiedName(), initialValue );
+                        status[ 0 ] = EntityStatus.UPDATED;
                     }
                 }
-                catch( JSONException e )
-                {
-                    // Value not found, default it
-                    Object initialValue = propertyDescriptor.initialValue( module );
-                    properties.put( propertyDescriptor.qualifiedName(), initialValue );
-                    status[ 0 ] = EntityStatus.UPDATED;
-                }
-            } );
+            );
 
             Map<QualifiedName, EntityReference> associations = new HashMap<>();
             JSONObject assocs = jsonObject.getJSONObject( JSONKeys.ASSOCIATIONS );
-            entityDescriptor.state().associations().forEach( associationType -> {
-                try
+            entityDescriptor.state().associations().forEach(
+                associationType ->
                 {
-                    Object jsonValue = assocs.get( associationType.qualifiedName().name() );
-                    EntityReference value = jsonValue == JSONObject.NULL ? null : EntityReference.parseEntityReference(
-                        (String) jsonValue );
-                    associations.put( associationType.qualifiedName(), value );
-                }
-                catch( JSONException e )
-                {
-                    // Association not found, default it to null
-                    associations.put( associationType.qualifiedName(), null );
-                    status[ 0 ] = EntityStatus.UPDATED;
+                    try
+                    {
+                        Object jsonValue = assocs.get( associationType.qualifiedName().name() );
+                        EntityReference value = jsonValue == JSONObject.NULL
+                                                ? null
+                                                : EntityReference.parseEntityReference( (String) jsonValue );
+                        associations.put( associationType.qualifiedName(), value );
+                    }
+                    catch( JSONException e )
+                    {
+                        // Association not found, default it to null
+                        associations.put( associationType.qualifiedName(), null );
+                        status[ 0 ] = EntityStatus.UPDATED;
+                    }
                 }
-            } );
+            );
 
             JSONObject manyAssocs = jsonObject.getJSONObject( JSONKeys.MANY_ASSOCIATIONS );
             Map<QualifiedName, List<EntityReference>> manyAssociations = new HashMap<>();
-            entityDescriptor.state().manyAssociations().forEach( manyAssociationType -> {
-                List<EntityReference> references = new ArrayList<>();
-                try
+            entityDescriptor.state().manyAssociations().forEach(
+                manyAssociationType ->
                 {
-                    JSONArray jsonValues = manyAssocs.getJSONArray( manyAssociationType.qualifiedName().name() );
-                    for( int i = 0; i < jsonValues.length(); i++ )
+                    List<EntityReference> references = new ArrayList<>();
+                    try
+                    {
+                        JSONArray jsonValues = manyAssocs.getJSONArray( manyAssociationType.qualifiedName().name() );
+                        for( int i = 0; i < jsonValues.length(); i++ )
+                        {
+                            Object jsonValue = jsonValues.getString( i );
+                            EntityReference value = jsonValue == JSONObject.NULL
+                                                    ? null
+                                                    : EntityReference.parseEntityReference( (String) jsonValue );
+                            references.add( value );
+                        }
+                        manyAssociations.put( manyAssociationType.qualifiedName(), references );
+                    }
+                    catch( JSONException e )
                     {
-                        Object jsonValue = jsonValues.getString( i );
-                        EntityReference value = jsonValue == JSONObject.NULL ? null : EntityReference.parseEntityReference(
-                            (String) jsonValue );
-                        references.add( value );
+                        // ManyAssociation not found, default to empty one
+                        manyAssociations.put( manyAssociationType.qualifiedName(), references );
                     }
-                    manyAssociations.put( manyAssociationType.qualifiedName(), references );
-                }
-                catch( JSONException e )
-                {
-                    // ManyAssociation not found, default to empty one
-                    manyAssociations.put( manyAssociationType.qualifiedName(), references );
-                }
-            } );
+                } );
 
             JSONObject namedAssocs = jsonObject.has( JSONKeys.NAMED_ASSOCIATIONS )
                                      ? jsonObject.getJSONObject( JSONKeys.NAMED_ASSOCIATIONS )
                                      : new JSONObject();
             Map<QualifiedName, Map<String, EntityReference>> namedAssociations = new HashMap<>();
-            entityDescriptor.state().namedAssociations().forEach( namedAssociationType -> {
-                Map<String, EntityReference> references = new LinkedHashMap<>();
-                try
+            entityDescriptor.state().namedAssociations().forEach(
+                namedAssociationType ->
                 {
-                    JSONObject jsonValues = namedAssocs.getJSONObject( namedAssociationType.qualifiedName().name() );
-                    JSONArray names = jsonValues.names();
-                    if( names != null )
+                    Map<String, EntityReference> references = new LinkedHashMap<>();
+                    try
                     {
-                        for( int idx = 0; idx < names.length(); idx++ )
+                        JSONObject jsonValues = namedAssocs.getJSONObject( namedAssociationType.qualifiedName().name() );
+                        JSONArray names = jsonValues.names();
+                        if( names != null )
                         {
-                            String name = names.getString( idx );
-                            String jsonValue = jsonValues.getString( name );
-                            references.put( name, EntityReference.parseEntityReference( jsonValue ) );
+                            for( int idx = 0; idx < names.length(); idx++ )
+                            {
+                                String name = names.getString( idx );
+                                String jsonValue = jsonValues.getString( name );
+                                references.put( name, EntityReference.parseEntityReference( jsonValue ) );
+                            }
                         }
+                        namedAssociations.put( namedAssociationType.qualifiedName(), references );
                     }
-                    namedAssociations.put( namedAssociationType.qualifiedName(), references );
-                }
-                catch( JSONException e )
-                {
-                    // NamedAssociation not found, default to empty one
-                    namedAssociations.put( namedAssociationType.qualifiedName(), references );
-                }
-            } );
+                    catch( JSONException e )
+                    {
+                        // NamedAssociation not found, default to empty one
+                        namedAssociations.put( namedAssociationType.qualifiedName(), references );
+                    }
+                } );
 
             return new DefaultEntityState( version, modified,
-                                           EntityReference.parseEntityReference( identity ), status[ 0 ], entityDescriptor,
+                                           EntityReference.parseEntityReference( identity ), status[ 0 ],
+                                           entityDescriptor,
                                            properties, associations, manyAssociations, namedAssociations );
         }
         catch( JSONException e )
@@ -507,7 +502,7 @@ public class SQLEntityStoreMixin
         throws IOException
     {
         JSONObject jsonObject;
-        try (Reader reader = getValue( EntityReference.parseEntityReference( id ) ).getReader())
+        try( Reader reader = getValue( EntityReference.parseEntityReference( id ) ).getReader() )
         {
             jsonObject = new JSONObject( new JSONTokener( reader ) );
         }
@@ -553,58 +548,65 @@ public class SQLEntityStoreMixin
         try
         {
             JSONWriter json = new JSONWriter( writer );
-            JSONWriter properties = json.object().
-                key( JSONKeys.IDENTITY ).value( state.entityReference().identity().toString() ).
-                key( JSONKeys.APPLICATION_VERSION ).value( application.version() ).
-                key( JSONKeys.TYPE ).value( state.entityDescriptor().types().findFirst().get().getName() ).
-                key( JSONKeys.VERSION ).value( version ).
-                key( JSONKeys.MODIFIED ).value( state.lastModified().toEpochMilli() ).
-                key( JSONKeys.PROPERTIES ).object();
-
-            state.entityDescriptor().state().properties().forEach( persistentProperty -> {
-                try
+            JSONWriter properties = json.object()
+                                        .key( JSONKeys.IDENTITY )
+                                        .value( state.entityReference().identity().toString() )
+                                        .key( JSONKeys.APPLICATION_VERSION )
+                                        .value( application.version() )
+                                        .key( JSONKeys.TYPE )
+                                        .value( state.entityDescriptor().types().findFirst().get().getName() )
+                                        .key( JSONKeys.VERSION )
+                                        .value( version )
+                                        .key( JSONKeys.MODIFIED )
+                                        .value( state.lastModified().toEpochMilli() )
+                                        .key( JSONKeys.PROPERTIES )
+                                        .object();
+
+            state.entityDescriptor().state().properties().forEach(
+                persistentProperty ->
                 {
-                    Object value = state.properties().get( persistentProperty.qualifiedName() );
-                    json.key( persistentProperty.qualifiedName().name() );
-                    if( value == null || ValueType.isPrimitiveValue( value ) )
+                    try
                     {
-                        json.value( value );
-                    }
-                    else
-                    {
-                        String serialized = valueSerialization.serialize( value );
-                        if( serialized.startsWith( "{" ) )
+                        Object value = state.properties().get( persistentProperty.qualifiedName() );
+                        json.key( persistentProperty.qualifiedName().name() );
+                        if( value == null || ValueType.isPrimitiveValue( value ) )
                         {
-                            json.value( new JSONObject( serialized ) );
-                        }
-                        else if( serialized.startsWith( "[" ) )
-                        {
-                            json.value( new JSONArray( serialized ) );
+                            json.value( value );
                         }
                         else
                         {
-                            json.value( serialized );
+                            String serialized = valueSerialization.serialize( value );
+                            if( serialized.startsWith( "{" ) )
+                            {
+                                json.value( new JSONObject( serialized ) );
+                            }
+                            else if( serialized.startsWith( "[" ) )
+                            {
+                                json.value( new JSONArray( serialized ) );
+                            }
+                            else
+                            {
+                                json.value( serialized );
+                            }
                         }
                     }
-                }
-                catch( JSONException e )
-                {
-                    throw new EntityStoreException( "Could not store EntityState", e );
-                }
-            } );
+                    catch( JSONException e )
+                    {
+                        throw new EntityStoreException(
+                            "Could not store EntityState", e );
+                    }
+                } );
 
             JSONWriter associations = properties.endObject().key( JSONKeys.ASSOCIATIONS ).object();
-            for( Map.Entry<QualifiedName, EntityReference> stateNameEntityReferenceEntry : state.associations()
-                .entrySet() )
+            for( Map.Entry<QualifiedName, EntityReference> stateNameEntityRefEntry : state.associations().entrySet() )
             {
-                EntityReference value = stateNameEntityReferenceEntry.getValue();
-                associations.key( stateNameEntityReferenceEntry.getKey().name() ).
-                    value( value != null ? value.identity().toString() : null );
+                EntityReference value = stateNameEntityRefEntry.getValue();
+                associations.key( stateNameEntityRefEntry.getKey().name() )
+                            .value( value != null ? value.identity().toString() : null );
             }
 
             JSONWriter manyAssociations = associations.endObject().key( JSONKeys.MANY_ASSOCIATIONS ).object();
-            for( Map.Entry<QualifiedName, List<EntityReference>> stateNameListEntry : state.manyAssociations()
-                .entrySet() )
+            for( Map.Entry<QualifiedName, List<EntityReference>> stateNameListEntry : state.manyAssociations().entrySet() )
             {
                 JSONWriter assocs = manyAssociations.key( stateNameListEntry.getKey().name() ).array();
                 for( EntityReference entityReference : stateNameListEntry.getValue() )
@@ -615,8 +617,7 @@ public class SQLEntityStoreMixin
             }
 
             JSONWriter namedAssociations = manyAssociations.endObject().key( JSONKeys.NAMED_ASSOCIATIONS ).object();
-            for( Map.Entry<QualifiedName, Map<String, EntityReference>> stateNameMapEntry : state.namedAssociations()
-                .entrySet() )
+            for( Map.Entry<QualifiedName, Map<String, EntityReference>> stateNameMapEntry : state.namedAssociations().entrySet() )
             {
                 JSONWriter assocs = namedAssociations.key( stateNameMapEntry.getKey().name() ).object();
                 for( Map.Entry<String, EntityReference> entry : stateNameMapEntry.getValue().entrySet() )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/extensions/migration/src/test/java/org/apache/zest/migration/MigrationTest.java
----------------------------------------------------------------------
diff --git a/extensions/migration/src/test/java/org/apache/zest/migration/MigrationTest.java b/extensions/migration/src/test/java/org/apache/zest/migration/MigrationTest.java
index 1da1f7b..7f8cb54 100644
--- a/extensions/migration/src/test/java/org/apache/zest/migration/MigrationTest.java
+++ b/extensions/migration/src/test/java/org/apache/zest/migration/MigrationTest.java
@@ -19,26 +19,18 @@
  */
 package org.apache.zest.migration;
 
-import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.StringReader;
-import org.apache.zest.api.identity.Identity;
-import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
-import org.hamcrest.CoreMatchers;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.junit.Test;
+import java.util.List;
+import java.util.stream.Stream;
 import org.apache.zest.api.activation.ActivationException;
+import org.apache.zest.api.identity.Identity;
 import org.apache.zest.api.service.importer.NewObjectImporter;
 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.bootstrap.SingletonAssembler;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.apache.zest.migration.assembly.EntityMigrationOperation;
 import org.apache.zest.migration.assembly.MigrationBuilder;
 import org.apache.zest.migration.assembly.MigrationOperation;
@@ -47,7 +39,12 @@ import org.apache.zest.spi.entitystore.helpers.JSONKeys;
 import org.apache.zest.spi.entitystore.helpers.StateStore;
 import org.apache.zest.test.AbstractZestTest;
 import org.apache.zest.test.EntityTestAssembler;
+import org.hamcrest.CoreMatchers;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.Test;
 
+import static java.util.stream.Collectors.toList;
 import static org.junit.Assert.assertThat;
 
 /**
@@ -106,7 +103,7 @@ public class MigrationTest
     {
         Identity id;
         // Set up version 1
-        StringInputOutput data_v1 = new StringInputOutput();
+        List<String> data_v1;
         {
             SingletonAssembler v1 = new SingletonAssembler()
             {
@@ -130,11 +127,14 @@ public class MigrationTest
             BackupRestore backupRestore = v1.module()
                 .findService( BackupRestore.class )
                 .get();
-            backupRestore.backup().transferTo( data_v1 );
+            try( Stream<String> backup = backupRestore.backup() )
+            {
+                data_v1 = backup.collect( toList() );
+            }
         }
 
         // Set up version 1.1
-        StringInputOutput data_v1_1 = new StringInputOutput();
+        List<String> data_v1_1;
         {
             SingletonAssembler v1_1 = new SingletonAssembler()
             {
@@ -148,7 +148,7 @@ public class MigrationTest
             };
 
             BackupRestore testData = v1_1.module().findService( BackupRestore.class ).get();
-            data_v1.transferTo( testData.restore() );
+            testData.restore( data_v1.stream() );
 
             UnitOfWork uow = v1_1.module().unitOfWorkFactory().newUnitOfWork();
             TestEntity1_1 entity = uow.get( TestEntity1_1.class, id );
@@ -157,7 +157,10 @@ public class MigrationTest
             assertThat( "Association has been renamed", entity.newFooAssoc().get(), CoreMatchers.equalTo( entity ) );
             uow.complete();
 
-            testData.backup().transferTo( data_v1_1 );
+            try( Stream<String> backup = testData.backup() )
+            {
+                data_v1_1 = backup.collect( toList() );
+            }
         }
 
         // Set up version 2.0
@@ -177,7 +180,7 @@ public class MigrationTest
 
             // Test migration from 1.0 -> 2.0
             {
-                data_v1.transferTo( testData.restore() );
+                testData.restore( data_v1.stream() );
                 UnitOfWork uow = v2_0.module().unitOfWorkFactory().newUnitOfWork();
                 TestEntity2_0 entity = uow.get( TestEntity2_0.class, id );
                 assertThat( "Property has been created", entity.bar().get(), CoreMatchers.equalTo( "Some value" ) );
@@ -202,11 +205,11 @@ public class MigrationTest
             };
 
             BackupRestore testData = v3_0.module().findService( BackupRestore.class ).get();
-            data_v1_1.transferTo( testData.restore() );
+            testData.restore( data_v1_1.stream() );
 
             // Test migration from 1.0 -> 3.0
             {
-                data_v1.transferTo( testData.restore() );
+                testData.restore( data_v1.stream() );
                 UnitOfWork uow = v3_0.module().unitOfWorkFactory().newUnitOfWork();
                 org.apache.zest.migration.moved.TestEntity2_0 entity = uow.get( org.apache.zest.migration.moved.TestEntity2_0.class, id );
                 uow.complete();
@@ -258,51 +261,4 @@ public class MigrationTest
             System.out.println( msg );
         }
     }
-
-    private static class StringInputOutput
-        implements Output<String, IOException>, Input<String, IOException>
-    {
-        final StringBuilder builder = new StringBuilder();
-
-        @Override
-        public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends String, SenderThrowableType> sender )
-            throws IOException, SenderThrowableType
-        {
-            sender.sendTo((Receiver<String, IOException>) item -> builder.append( item ).append( "\n" ));
-        }
-
-        @Override
-        public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super String, ReceiverThrowableType> output )
-            throws IOException, ReceiverThrowableType
-        {
-            output.receiveFrom( new Sender<String, IOException>()
-            {
-                @Override
-                public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super String, ReceiverThrowableType> receiver )
-                    throws ReceiverThrowableType, IOException
-                {
-                    BufferedReader reader = new BufferedReader( new StringReader( builder.toString() ) );
-                    String line;
-                    try
-                    {
-                        while( ( line = reader.readLine() ) != null )
-                        {
-                            receiver.receive( line );
-                        }
-                    }
-                    finally
-                    {
-                        reader.close();
-                    }
-                }
-            } );
-        }
-
-        @Override
-        public String toString()
-        {
-            return builder.toString();
-        }
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/extensions/reindexer/src/main/java/org/apache/zest/index/reindexer/internal/ReindexerMixin.java
----------------------------------------------------------------------
diff --git a/extensions/reindexer/src/main/java/org/apache/zest/index/reindexer/internal/ReindexerMixin.java b/extensions/reindexer/src/main/java/org/apache/zest/index/reindexer/internal/ReindexerMixin.java
index c3a3af4..f11dc77 100644
--- a/extensions/reindexer/src/main/java/org/apache/zest/index/reindexer/internal/ReindexerMixin.java
+++ b/extensions/reindexer/src/main/java/org/apache/zest/index/reindexer/internal/ReindexerMixin.java
@@ -21,7 +21,7 @@
 package org.apache.zest.index.reindexer.internal;
 
 import java.util.ArrayList;
-import org.apache.zest.api.common.QualifiedName;
+import java.util.stream.Stream;
 import org.apache.zest.api.configuration.Configuration;
 import org.apache.zest.api.identity.HasIdentity;
 import org.apache.zest.api.injection.scope.Service;
@@ -31,9 +31,6 @@ import org.apache.zest.api.service.ServiceReference;
 import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.index.reindexer.Reindexer;
 import org.apache.zest.index.reindexer.ReindexerConfiguration;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
 import org.apache.zest.spi.entity.EntityState;
 import org.apache.zest.spi.entitystore.EntityStore;
 import org.apache.zest.spi.entitystore.StateChangeListener;
@@ -67,52 +64,43 @@ public class ReindexerMixin
         {
             loadValue = 50;
         }
-        new ReindexerOutput( loadValue ).reindex( store );
+        ReindexerHelper helper = new ReindexerHelper( loadValue );
+        helper.reindex( store );
     }
 
-    private class ReindexerOutput
-        implements Output<EntityState, RuntimeException>, Receiver<EntityState, RuntimeException>
+    private class ReindexerHelper
     {
         private int count;
         private int loadValue;
         private ArrayList<EntityState> states;
 
-        public ReindexerOutput( Integer loadValue )
+        private ReindexerHelper( int loadValue )
         {
             this.loadValue = loadValue;
             states = new ArrayList<>();
         }
 
-        public void reindex( EntityStore store )
+        private void reindex( EntityStore store )
         {
-
-            store.entityStates( module ).transferTo( this );
-            reindexState();
-        }
-
-        @Override
-        public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends EntityState, SenderThrowableType> sender )
-            throws RuntimeException, SenderThrowableType
-        {
-            sender.sendTo( this );
-            reindexState();
-        }
-
-        @Override
-        public void receive( EntityState item )
-            throws RuntimeException
-        {
-            count++;
-            item.setPropertyValue( HasIdentity.IDENTITY_STATE_NAME, item.entityReference().identity() );
-            states.add( item );
-
-            if( states.size() >= loadValue )
+            try( Stream<EntityState> entityStates = store.entityStates( module ) )
             {
-                reindexState();
+                entityStates
+                    .forEach( entityState ->
+                              {
+                                  count++;
+                                  entityState.setPropertyValue( HasIdentity.IDENTITY_STATE_NAME,
+                                                                entityState.entityReference().identity() );
+                                  states.add( entityState );
+                                  if( states.size() >= loadValue )
+                                  {
+                                      reindexState();
+                                  }
+                              } );
             }
+            reindexState();
         }
 
-        public void reindexState()
+        private void reindexState()
         {
             for( ServiceReference<StateChangeListener> listener : listeners )
             {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java
----------------------------------------------------------------------
diff --git a/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java b/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java
index ae75fb4..1fccdde 100644
--- a/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java
+++ b/libraries/logging/src/test/java/org/apache/zest/library/logging/DebuggingTest.java
@@ -20,9 +20,8 @@
 
 package org.apache.zest.library.logging;
 
-import java.util.function.Function;
+import java.util.stream.Stream;
 import org.apache.zest.api.identity.Identity;
-import org.junit.Test;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.mixin.Mixins;
 import org.apache.zest.api.service.ServiceComposite;
@@ -31,8 +30,6 @@ 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.io.Outputs;
-import org.apache.zest.io.Transforms;
 import org.apache.zest.library.logging.debug.Debug;
 import org.apache.zest.library.logging.debug.DebugConcern;
 import org.apache.zest.library.logging.debug.records.ServiceDebugRecordEntity;
@@ -42,6 +39,7 @@ import org.apache.zest.spi.entity.EntityState;
 import org.apache.zest.spi.entitystore.EntityStore;
 import org.apache.zest.test.AbstractZestTest;
 import org.apache.zest.test.EntityTestAssembler;
+import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 
@@ -76,19 +74,18 @@ public class DebuggingTest
             assertEquals( message, "Hello!" );
             EntityStore es = serviceFinder.findService( EntityStore.class ).get();
             final Identity[] result = new Identity[1];
-            es.entityStates( module ).transferTo( Transforms.map( new Function<EntityState, EntityState>()
-                    {
-                        public EntityState apply( EntityState entityState )
-                        {
-                            if( ServiceDebugRecordEntity.class.getName()
-                                    .equals( entityState.entityDescriptor().types().findFirst().get().getName() ) )
-                            {
-                                result[0] = entityState.entityReference().identity();
-                            }
-
-                            return entityState;
-                        }
-                    }, Outputs.<EntityState>noop() ));
+            try( Stream<EntityState> entityStates = es.entityStates( module ) )
+            {
+                entityStates
+                    .forEach( entityState ->
+                              {
+                                  if( ServiceDebugRecordEntity.class.getName().equals(
+                                      entityState.entityDescriptor().types().findFirst().get().getName() ) )
+                                  {
+                                      result[ 0 ] = entityState.entityReference().identity();
+                                  }
+                              } );
+            }
 
             ServiceDebugRecordEntity debugEntry = uow.get( ServiceDebugRecordEntity.class, result[ 0 ] );
             String mess = debugEntry.message().get();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/libraries/sql/src/main/java/org/apache/zest/library/sql/common/SQLUtil.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/main/java/org/apache/zest/library/sql/common/SQLUtil.java b/libraries/sql/src/main/java/org/apache/zest/library/sql/common/SQLUtil.java
index 12a2bd4..e87c9c6 100644
--- a/libraries/sql/src/main/java/org/apache/zest/library/sql/common/SQLUtil.java
+++ b/libraries/sql/src/main/java/org/apache/zest/library/sql/common/SQLUtil.java
@@ -26,43 +26,94 @@ import java.sql.Statement;
 
 public class SQLUtil
 {
-
     public static void closeQuietly( ResultSet resultSet )
     {
-        if ( resultSet != null ) {
-            try {
+        closeQuietly( resultSet, null );
+    }
+
+    public static void closeQuietly( ResultSet resultSet, Throwable originalException )
+    {
+        if( resultSet != null )
+        {
+            try
+            {
                 resultSet.close();
-            } catch ( SQLException ignored ) {
+            }
+            catch( SQLException ignored )
+            {
+                if( originalException != null )
+                {
+                    originalException.addSuppressed( ignored );
+                }
             }
         }
     }
 
     public static void closeQuietly( Statement select )
     {
-        if ( select != null ) {
-            try {
+        closeQuietly( select, null );
+    }
+
+    public static void closeQuietly( Statement select, Throwable originalException )
+    {
+        if( select != null )
+        {
+            try
+            {
                 select.close();
-            } catch ( SQLException ignored ) {
+            }
+            catch( SQLException ignored )
+            {
+                if( originalException != null )
+                {
+                    originalException.addSuppressed( ignored );
+                }
             }
         }
     }
 
     public static void closeQuietly( Connection connection )
     {
-        if ( connection != null ) {
-            try {
+        closeQuietly( connection, null );
+    }
+
+    public static void closeQuietly( Connection connection, Throwable originalException )
+    {
+        if( connection != null )
+        {
+            try
+            {
                 connection.close();
-            } catch ( SQLException ignored ) {
+            }
+            catch( SQLException ignored )
+            {
+                if( originalException != null )
+                {
+                    originalException.addSuppressed( ignored );
+                }
             }
         }
     }
 
     public static void rollbackQuietly( Connection connection )
     {
-        if ( connection != null ) {
-            try {
+        rollbackQuietly( connection, null );
+    }
+
+    public static void rollbackQuietly( Connection connection, Throwable originalException )
+    {
+        if( connection != null )
+        {
+            try
+            {
                 connection.rollback();
-            } catch ( SQLException ignored ) {
+            }
+            catch( SQLException ignored )
+            {
+                if( originalException != null )
+                {
+                    originalException.addSuppressed( ignored );
+                }
             }
         }
     }
@@ -70,5 +121,4 @@ public class SQLUtil
     private SQLUtil()
     {
     }
-
 }


[6/7] zest-java git commit: Remove core/functional

Posted by pa...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 2bcfc54..76a3c52 100644
--- 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
@@ -29,8 +29,8 @@ 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.ModuleDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.activation.ActivatorsInstance;
 import org.apache.zest.runtime.activation.ActivatorsModel;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index b7d9162..9a07ebe 100644
--- 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
@@ -25,8 +25,8 @@ import java.util.List;
 import java.util.stream.Stream;
 import org.apache.zest.api.service.ServiceReference;
 import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 /**
  * JAVADOC

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 2083c94..d5e4c4a 100644
--- 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
@@ -35,7 +35,7 @@ import org.apache.zest.api.property.Property;
 import org.apache.zest.api.service.ServiceDescriptor;
 import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.api.util.Classes;
-import org.apache.zest.functional.HierarchicalVisitor;
+import org.apache.zest.api.util.HierarchicalVisitor;
 import org.apache.zest.runtime.activation.ActivatorsInstance;
 import org.apache.zest.runtime.activation.ActivatorsModel;
 import org.apache.zest.runtime.composite.CompositeMethodsModel;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 3a926d0..d72d58e 100644
--- 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
@@ -26,8 +26,8 @@ import java.util.stream.Stream;
 import org.apache.zest.api.service.ServiceDescriptor;
 import org.apache.zest.api.service.ServiceReference;
 import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 /**
  * JAVADOC

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 29c78fb..85c38a2 100644
--- 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
@@ -30,8 +30,8 @@ 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.LayerDescriptor;
+import org.apache.zest.api.util.HierarchicalVisitor;
 import org.apache.zest.bootstrap.ZestRuntime;
-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;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index d0f3321..16f7a51 100644
--- 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
@@ -30,9 +30,9 @@ import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.object.ObjectDescriptor;
 import org.apache.zest.api.structure.Layer;
 import org.apache.zest.api.structure.LayerDescriptor;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.api.value.ValueDescriptor;
-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;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 2c7be06..cf0b4a9 100644
--- 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
@@ -33,9 +33,9 @@ import org.apache.zest.api.structure.LayerDescriptor;
 import org.apache.zest.api.structure.Module;
 import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.api.structure.TypeLookup;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.api.value.ValueDescriptor;
-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;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index e12258c..d13704f 100644
--- 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
@@ -24,8 +24,8 @@ import java.util.List;
 import java.util.stream.Stream;
 import org.apache.zest.api.structure.LayerDescriptor;
 import org.apache.zest.api.structure.UsedLayersDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 /**
  * JAVADOC

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 427ce43..a957809 100644
--- 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
@@ -35,8 +35,8 @@ 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.util.HierarchicalVisitorAdapter;
 import org.apache.zest.api.value.ValueComposite;
-import org.apache.zest.functional.HierarchicalVisitorAdapter;
 import org.apache.zest.runtime.association.AssociationsModel;
 import org.apache.zest.runtime.association.ManyAssociationsModel;
 import org.apache.zest.runtime.association.NamedAssociationsModel;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index cb2a093..b8be640 100644
--- 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
@@ -23,8 +23,8 @@ import java.util.stream.Stream;
 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.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.association.AssociationModel;
 import org.apache.zest.runtime.association.AssociationsModel;
 import org.apache.zest.runtime.association.ManyAssociationModel;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index a8b95f2..1988101 100644
--- 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
@@ -22,9 +22,9 @@ package org.apache.zest.runtime.value;
 
 import java.util.List;
 import java.util.stream.Stream;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
 
 /**
  * JAVADOC

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/core/runtime/src/test/java/org/apache/zest/bootstrap/ApplicationAssemblerTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/bootstrap/ApplicationAssemblerTest.java b/core/runtime/src/test/java/org/apache/zest/bootstrap/ApplicationAssemblerTest.java
index 7dad851..eeaef1a 100644
--- a/core/runtime/src/test/java/org/apache/zest/bootstrap/ApplicationAssemblerTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/bootstrap/ApplicationAssemblerTest.java
@@ -29,7 +29,7 @@ import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.service.ServiceComposite;
 import org.apache.zest.api.service.ServiceDescriptor;
 import org.apache.zest.api.structure.ApplicationDescriptor;
-import org.apache.zest.functional.HierarchicalVisitorAdapter;
+import org.apache.zest.api.util.HierarchicalVisitorAdapter;
 
 /**
  * TODO

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/core/runtime/src/test/java/org/apache/zest/regression/qi78/IssueTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/regression/qi78/IssueTest.java b/core/runtime/src/test/java/org/apache/zest/regression/qi78/IssueTest.java
index ed69d70..a92816d 100644
--- a/core/runtime/src/test/java/org/apache/zest/regression/qi78/IssueTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/regression/qi78/IssueTest.java
@@ -22,13 +22,13 @@ package org.apache.zest.regression.qi78;
 import org.apache.zest.api.structure.Application;
 import org.apache.zest.api.structure.ApplicationDescriptor;
 import org.apache.zest.api.structure.LayerDescriptor;
+import org.apache.zest.api.util.HierarchicalVisitorAdapter;
 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;
-import org.apache.zest.functional.HierarchicalVisitorAdapter;
 import org.junit.Assert;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java
index 671785a..1677027 100644
--- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java
+++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java
@@ -65,8 +65,8 @@ import org.apache.zest.api.structure.Application;
 import org.apache.zest.api.structure.ApplicationDescriptor;
 import org.apache.zest.api.structure.LayerDescriptor;
 import org.apache.zest.api.structure.ModuleDescriptor;
+import org.apache.zest.api.util.HierarchicalVisitorAdapter;
 import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.functional.HierarchicalVisitorAdapter;
 import org.apache.zest.index.reindexer.Reindexer;
 import org.apache.zest.index.sql.support.api.SQLAppStartup;
 import org.apache.zest.index.sql.support.api.SQLTypeInfo;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/Browser.java
----------------------------------------------------------------------
diff --git a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/Browser.java b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/Browser.java
index de290c8..5757df9 100644
--- a/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/Browser.java
+++ b/libraries/appbrowser/src/main/java/org/apache/zest/library/appbrowser/Browser.java
@@ -21,7 +21,7 @@ package org.apache.zest.library.appbrowser;
 import java.util.Stack;
 import org.json.JSONException;
 import org.apache.zest.api.structure.ApplicationDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
+import org.apache.zest.api.util.HierarchicalVisitor;
 
 public class Browser
 {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/libraries/circuitbreaker/src/docs/circuitbreaker.txt
----------------------------------------------------------------------
diff --git a/libraries/circuitbreaker/src/docs/circuitbreaker.txt b/libraries/circuitbreaker/src/docs/circuitbreaker.txt
index b30cf47..b6779c6 100644
--- a/libraries/circuitbreaker/src/docs/circuitbreaker.txt
+++ b/libraries/circuitbreaker/src/docs/circuitbreaker.txt
@@ -44,7 +44,7 @@ of exceptions cause the circuit to break. The most crude is "all", more
 advanced ones allow exceptions that be excepted to be registered, but in
 real cases this is not enough. Case in point is JDBC exceptions where
 you want to fail on "connect exception" but not necessarily "invalid SQL
-syntax". So instead we've leveraged `Specification` from <<core-functional,Core Functional API>> where
+syntax". So instead we've leveraged `Predicate` where
 you get to provide your own specification that can use any logic to
 determine whether a particular exception is ok or not.
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ApplicationManagerService.java
----------------------------------------------------------------------
diff --git a/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ApplicationManagerService.java b/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ApplicationManagerService.java
index 137b428..8ad1b21 100644
--- a/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ApplicationManagerService.java
+++ b/libraries/jmx/src/main/java/org/apache/zest/library/jmx/ApplicationManagerService.java
@@ -45,7 +45,7 @@ import org.apache.zest.api.structure.Layer;
 import org.apache.zest.api.structure.LayerDescriptor;
 import org.apache.zest.api.structure.Module;
 import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.functional.HierarchicalVisitorAdapter;
+import org.apache.zest.api.util.HierarchicalVisitorAdapter;
 
 import static org.apache.zest.api.service.qualifier.ServiceQualifier.withId;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/libraries/rdf/src/main/java/org/apache/zest/library/rdf/model/ApplicationVisitor.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/main/java/org/apache/zest/library/rdf/model/ApplicationVisitor.java b/libraries/rdf/src/main/java/org/apache/zest/library/rdf/model/ApplicationVisitor.java
index 7ff88a9..419f4e2 100644
--- a/libraries/rdf/src/main/java/org/apache/zest/library/rdf/model/ApplicationVisitor.java
+++ b/libraries/rdf/src/main/java/org/apache/zest/library/rdf/model/ApplicationVisitor.java
@@ -27,7 +27,7 @@ import org.apache.zest.api.object.ObjectDescriptor;
 import org.apache.zest.api.structure.ApplicationDescriptor;
 import org.apache.zest.api.structure.LayerDescriptor;
 import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.functional.HierarchicalVisitorAdapter;
+import org.apache.zest.api.util.HierarchicalVisitorAdapter;
 import org.apache.zest.library.rdf.ZestRdf;
 import org.apache.zest.library.rdf.serializer.SerializerContext;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/libraries/rdf/src/main/java/org/apache/zest/library/rdf/model/Model2XML.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/main/java/org/apache/zest/library/rdf/model/Model2XML.java b/libraries/rdf/src/main/java/org/apache/zest/library/rdf/model/Model2XML.java
index 388d005..e9c1d78 100644
--- a/libraries/rdf/src/main/java/org/apache/zest/library/rdf/model/Model2XML.java
+++ b/libraries/rdf/src/main/java/org/apache/zest/library/rdf/model/Model2XML.java
@@ -32,7 +32,7 @@ import org.apache.zest.api.mixin.MixinDescriptor;
 import org.apache.zest.api.structure.ApplicationDescriptor;
 import org.apache.zest.api.structure.LayerDescriptor;
 import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
+import org.apache.zest.api.util.HierarchicalVisitor;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceLocator.java
----------------------------------------------------------------------
diff --git a/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceLocator.java b/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceLocator.java
index 885b515..6dbaf3c 100644
--- a/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceLocator.java
+++ b/libraries/spring/src/main/java/org/apache/zest/library/spring/bootstrap/internal/service/ServiceLocator.java
@@ -28,7 +28,7 @@ import org.apache.zest.api.structure.ApplicationDescriptor;
 import org.apache.zest.api.structure.LayerDescriptor;
 import org.apache.zest.api.structure.Module;
 import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
+import org.apache.zest.api.util.HierarchicalVisitor;
 
 final class ServiceLocator
     implements HierarchicalVisitor<Object, Object, RuntimeException>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/libraries/sql/src/main/java/org/apache/zest/library/sql/common/Databases.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/main/java/org/apache/zest/library/sql/common/Databases.java b/libraries/sql/src/main/java/org/apache/zest/library/sql/common/Databases.java
index 4d66954..a27f445 100644
--- a/libraries/sql/src/main/java/org/apache/zest/library/sql/common/Databases.java
+++ b/libraries/sql/src/main/java/org/apache/zest/library/sql/common/Databases.java
@@ -24,7 +24,7 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import javax.sql.DataSource;
-import org.apache.zest.functional.Visitor;
+import org.apache.zest.api.util.Visitor;
 
 /**
  * Utility methods for performing SQL calls wrapping a given DataSource.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/manual/src/docs/userguide/core.txt
----------------------------------------------------------------------
diff --git a/manual/src/docs/userguide/core.txt b/manual/src/docs/userguide/core.txt
index 588de3c..9c02353 100644
--- a/manual/src/docs/userguide/core.txt
+++ b/manual/src/docs/userguide/core.txt
@@ -64,17 +64,6 @@ if ever, needed.
 <<core-testsupport,Learn more>>
 //____
 
-//*<<core-functional,Core Functional API>>*
-=== Core Functional API ===
-//____
-The Zest\u2122 Core Functional API is a generic package to work with Iterables in a "functional programming language" style.
-
-This package is completely independent of everything else in Zest\u2122 and may be used on its own in any kind of environment
-such as Spring or Java EE applications.
-
-<<core-functional,Learn more>>
-//____
-
 //*<<core-spi,Core Extension SPI>>*
 === Core Extension SPI ===
 //____
@@ -110,10 +99,6 @@ include::../../../../core/testsupport/src/docs/testsupport.txt[]
 
 :leveloffset: 2
 
-include::../../../../core/functional/src/docs/functional.txt[]
-
-:leveloffset: 2
-
 include::../../../../core/spi/src/docs/spi.txt[]
 
 :leveloffset: 2

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/settings.gradle
----------------------------------------------------------------------
diff --git a/settings.gradle b/settings.gradle
index 97a817f..2e4589b 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -18,8 +18,7 @@
  *
  */
 
-include 'core:functional',
-        'core:api',
+include 'core:api',
         'core:spi',
         'core:testsupport',
         'core:bootstrap',

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ActivatorDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ActivatorDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ActivatorDetailDescriptor.java
index 5522116..5a3ed30 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ActivatorDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ActivatorDetailDescriptor.java
@@ -22,8 +22,8 @@ package org.apache.zest.tools.model.descriptor;
 import java.util.LinkedList;
 import java.util.List;
 import org.apache.zest.api.activation.ActivatorDescriptor;
-import org.apache.zest.functional.Visitable;
-import org.apache.zest.functional.Visitor;
+import org.apache.zest.api.util.Visitable;
+import org.apache.zest.api.util.Visitor;
 
 import static org.apache.zest.api.util.NullArgumentException.validateNotNull;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ApplicationDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ApplicationDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ApplicationDetailDescriptor.java
index d4d73bb..f961871 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ApplicationDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ApplicationDetailDescriptor.java
@@ -22,8 +22,8 @@ package org.apache.zest.tools.model.descriptor;
 import java.util.LinkedList;
 import java.util.List;
 import org.apache.zest.api.structure.ApplicationDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 import static org.apache.zest.api.util.NullArgumentException.validateNotNull;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ApplicationDetailDescriptorBuilder.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ApplicationDetailDescriptorBuilder.java b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ApplicationDetailDescriptorBuilder.java
index 25f5e71..ac373c3 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ApplicationDetailDescriptorBuilder.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ApplicationDetailDescriptorBuilder.java
@@ -42,8 +42,8 @@ import org.apache.zest.api.sideeffect.SideEffectsDescriptor;
 import org.apache.zest.api.structure.ApplicationDescriptor;
 import org.apache.zest.api.structure.LayerDescriptor;
 import org.apache.zest.api.structure.ModuleDescriptor;
+import org.apache.zest.api.util.HierarchicalVisitor;
 import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
 
 public final class ApplicationDetailDescriptorBuilder
 {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/EntityDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/EntityDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/EntityDetailDescriptor.java
index 5d5fac2..fb61684 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/EntityDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/EntityDetailDescriptor.java
@@ -20,8 +20,8 @@
 package org.apache.zest.tools.model.descriptor;
 
 import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.functional.Visitable;
-import org.apache.zest.functional.Visitor;
+import org.apache.zest.api.util.Visitable;
+import org.apache.zest.api.util.Visitor;
 
 /**
  * Entity Detail Descriptor.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ImportedServiceDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ImportedServiceDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ImportedServiceDetailDescriptor.java
index 4b9c852..81f7048 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ImportedServiceDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ImportedServiceDetailDescriptor.java
@@ -21,8 +21,8 @@ package org.apache.zest.tools.model.descriptor;
 
 import java.util.LinkedList;
 import java.util.List;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 import static org.apache.zest.api.util.NullArgumentException.validateNotNull;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/LayerDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/LayerDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/LayerDetailDescriptor.java
index 7db0ae0..4b96369 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/LayerDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/LayerDetailDescriptor.java
@@ -22,8 +22,8 @@ package org.apache.zest.tools.model.descriptor;
 import java.util.LinkedList;
 import java.util.List;
 import org.apache.zest.api.structure.LayerDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 import static org.apache.zest.api.util.NullArgumentException.validateNotNull;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ModuleDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ModuleDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ModuleDetailDescriptor.java
index 6bcb8b3..e34c6ff 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ModuleDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ModuleDetailDescriptor.java
@@ -22,8 +22,8 @@ package org.apache.zest.tools.model.descriptor;
 import java.util.LinkedList;
 import java.util.List;
 import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 import static org.apache.zest.api.util.NullArgumentException.validateNotNull;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ObjectDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ObjectDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ObjectDetailDescriptor.java
index a878222..5e05a9c 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ObjectDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ObjectDetailDescriptor.java
@@ -22,8 +22,8 @@ package org.apache.zest.tools.model.descriptor;
 import java.util.LinkedList;
 import java.util.List;
 import org.apache.zest.api.object.ObjectDescriptor;
-import org.apache.zest.functional.Visitable;
-import org.apache.zest.functional.Visitor;
+import org.apache.zest.api.util.Visitable;
+import org.apache.zest.api.util.Visitor;
 
 import static org.apache.zest.api.util.NullArgumentException.validateNotNull;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ServiceDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ServiceDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ServiceDetailDescriptor.java
index 764b22e..e9ff57d 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ServiceDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ServiceDetailDescriptor.java
@@ -23,8 +23,8 @@ import java.util.LinkedList;
 import java.util.List;
 import org.apache.zest.api.common.Visibility;
 import org.apache.zest.api.service.ServiceDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 import static org.apache.zest.api.util.NullArgumentException.validateNotNull;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/TransientDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/TransientDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/TransientDetailDescriptor.java
index 27e6391..598f850 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/TransientDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/TransientDetailDescriptor.java
@@ -20,8 +20,8 @@
 package org.apache.zest.tools.model.descriptor;
 
 import org.apache.zest.api.composite.TransientDescriptor;
-import org.apache.zest.functional.Visitable;
-import org.apache.zest.functional.Visitor;
+import org.apache.zest.api.util.Visitable;
+import org.apache.zest.api.util.Visitor;
 
 /**
  * Transient Detail Descriptor.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ValueDetailDescriptor.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ValueDetailDescriptor.java b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ValueDetailDescriptor.java
index c8d71fb..e1c7767 100644
--- a/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ValueDetailDescriptor.java
+++ b/tools/model-detail/src/main/java/org/apache/zest/tools/model/descriptor/ValueDetailDescriptor.java
@@ -20,8 +20,8 @@
 package org.apache.zest.tools.model.descriptor;
 
 import org.apache.zest.api.value.ValueDescriptor;
-import org.apache.zest.functional.Visitable;
-import org.apache.zest.functional.Visitor;
+import org.apache.zest.api.util.Visitable;
+import org.apache.zest.api.util.Visitor;
 
 /**
  * Value Detail Descriptor.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/tools/model-detail/src/test/java/org/apache/zest/tools/model/VisitableDetailTest.java
----------------------------------------------------------------------
diff --git a/tools/model-detail/src/test/java/org/apache/zest/tools/model/VisitableDetailTest.java b/tools/model-detail/src/test/java/org/apache/zest/tools/model/VisitableDetailTest.java
index 177eac2..00112c6 100644
--- a/tools/model-detail/src/test/java/org/apache/zest/tools/model/VisitableDetailTest.java
+++ b/tools/model-detail/src/test/java/org/apache/zest/tools/model/VisitableDetailTest.java
@@ -31,14 +31,12 @@ 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.ApplicationAssembler;
+import org.apache.zest.api.util.HierarchicalVisitor;
 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;
 import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.functional.HierarchicalVisitor;
 import org.apache.zest.tools.model.descriptor.ApplicationDetailDescriptor;
 
 import static org.hamcrest.CoreMatchers.equalTo;


[2/7] zest-java git commit: entitystores: replace usage of core/io with streams

Posted by pa...@apache.org.
entitystores: replace usage of core/io with streams


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

Branch: refs/heads/develop
Commit: ee1d1abccdd5e978f6a5216f1265958825139925
Parents: 8854b13
Author: Paul Merlin <pa...@apache.org>
Authored: Sat Dec 3 12:12:22 2016 +0100
Committer: Paul Merlin <pa...@apache.org>
Committed: Fri Dec 9 09:26:40 2016 +0100

----------------------------------------------------------------------
 .../memory/MemoryMapEntityStoreMixin.java       | 107 ++----
 .../zest/spi/entitystore/BackupRestore.java     |  25 +-
 .../zest/spi/entitystore/EntityStore.java       |  10 +-
 .../helpers/JSONMapEntityStoreMixin.java        | 125 +++----
 .../spi/entitystore/helpers/MapEntityStore.java |   6 +-
 .../helpers/MapEntityStoreMixin.java            | 112 +++---
 .../test/entity/AbstractEntityStoreTest.java    |  32 ++
 .../entitystore/file/FileEntityStoreMixin.java  |  98 ++----
 .../geode/GeodeEntityStoreMixin.java            |  29 +-
 .../hazelcast/HazelcastEntityStoreMixin.java    |  29 +-
 .../jclouds/JCloudsMapEntityStoreMixin.java     |  73 ++--
 .../entitystore/jdbm/JdbmEntityStoreMixin.java  | 293 ++++++++--------
 .../leveldb/LevelDBEntityStoreMixin.java        |  65 ++--
 .../mongodb/MongoMapEntityStoreMixin.java       |  42 +--
 .../prefs/PreferencesEntityStoreMixin.java      |  55 +--
 .../redis/RedisMapEntityStoreMixin.java         |  42 +--
 .../riak/RiakMapEntityStoreMixin.java           |  82 ++---
 .../entitystore/sql/SQLEntityStoreMixin.java    | 337 ++++++++++---------
 .../apache/zest/migration/MigrationTest.java    |  90 ++---
 .../reindexer/internal/ReindexerMixin.java      |  54 ++-
 .../zest/library/logging/DebuggingTest.java     |  31 +-
 .../apache/zest/library/sql/common/SQLUtil.java |  78 ++++-
 22 files changed, 739 insertions(+), 1076 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/core/spi/src/main/java/org/apache/zest/entitystore/memory/MemoryMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/entitystore/memory/MemoryMapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/zest/entitystore/memory/MemoryMapEntityStoreMixin.java
index 893e17a..79ad54d 100644
--- a/core/spi/src/main/java/org/apache/zest/entitystore/memory/MemoryMapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/zest/entitystore/memory/MemoryMapEntityStoreMixin.java
@@ -23,18 +23,13 @@ import java.io.IOException;
 import java.io.Reader;
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.io.UncheckedIOException;
 import java.io.Writer;
 import java.util.HashMap;
 import java.util.Map;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.JSONTokener;
+import java.util.stream.Stream;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
 import org.apache.zest.spi.entitystore.BackupRestore;
 import org.apache.zest.spi.entitystore.EntityAlreadyExistsException;
 import org.apache.zest.spi.entitystore.EntityNotFoundException;
@@ -42,6 +37,9 @@ import org.apache.zest.spi.entitystore.EntityStoreException;
 import org.apache.zest.spi.entitystore.helpers.JSONKeys;
 import org.apache.zest.spi.entitystore.helpers.MapEntityStore;
 import org.apache.zest.spi.entitystore.helpers.MapEntityStoreActivation;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.json.JSONTokener;
 
 /**
  * In-memory implementation of MapEntityStore.
@@ -90,95 +88,34 @@ public class MemoryMapEntityStoreMixin
     }
 
     @Override
-    public Input<Reader, IOException> entityStates()
+    public Stream<Reader> entityStates()
     {
-        return new Input<Reader, IOException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super Reader, ReceiverThrowableType> output )
-                throws IOException, ReceiverThrowableType
-            {
-                output.receiveFrom( new Sender<Reader, IOException>()
-                {
-                    @Override
-                    public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super Reader, ReceiverThrowableType> receiver )
-                        throws ReceiverThrowableType, IOException
-                    {
-                        for( String state : store.values() )
-                        {
-                            receiver.receive( new StringReader( state ) );
-                        }
-                    }
-                } );
-            }
-        };
+        return store.values().stream().map( StringReader::new );
     }
 
     @Override
-    public Input<String, IOException> backup()
+    public Stream<String> backup()
     {
-        return new Input<String, IOException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super String, ReceiverThrowableType> output )
-                throws IOException, ReceiverThrowableType
-            {
-                output.receiveFrom( new Sender<String, IOException>()
-                {
-                    @Override
-                    public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super String, ReceiverThrowableType> receiver )
-                        throws ReceiverThrowableType, IOException
-                    {
-                        for( String state : store.values() )
-                        {
-                            receiver.receive( state );
-                        }
-                    }
-                } );
-            }
-        };
+        return store.values().stream();
     }
 
     @Override
-    public Output<String, IOException> restore()
+    public void restore( final Stream<String> stream )
     {
-        return new Output<String, IOException>()
-        {
-            @Override
-            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends String, SenderThrowableType> sender )
-                throws IOException, SenderThrowableType
+        store.clear();
+        stream.forEach( item -> {
+            try
             {
-                store.clear();
-
-                try
-                {
-                    sender.sendTo( new Receiver<String, IOException>()
-                    {
-                        @Override
-                        public void receive( String item )
-                            throws IOException
-                        {
-                            try
-                            {
-                                JSONTokener tokener = new JSONTokener( item );
-                                JSONObject entity = (JSONObject) tokener.nextValue();
-                                String id = entity.getString( JSONKeys.IDENTITY );
-                                store.put( EntityReference.parseEntityReference( id ), item );
-                            }
-                            catch( JSONException e )
-                            {
-                                throw new IOException( e );
-                            }
-                        }
-                    } );
-                }
-                catch( IOException e )
-                {
-                    store.clear();
-                    throw e;
-                }
+                JSONTokener tokener = new JSONTokener( item );
+                JSONObject entity = (JSONObject) tokener.nextValue();
+                String id = entity.getString( JSONKeys.IDENTITY );
+                store.put( EntityReference.parseEntityReference( id ), item );
+            }
+            catch( JSONException e )
+            {
+                throw new UncheckedIOException( new IOException( e ) );
             }
-        };
+        } );
     }
 
     private class MemoryMapChanger

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/core/spi/src/main/java/org/apache/zest/spi/entitystore/BackupRestore.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/BackupRestore.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/BackupRestore.java
index e7cb5be..63aa3aa 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/BackupRestore.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/BackupRestore.java
@@ -20,9 +20,8 @@
 
 package org.apache.zest.spi.entitystore;
 
-import java.io.IOException;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
+import java.util.function.Consumer;
+import java.util.stream.Stream;
 
 /**
  * Allow backups and restores of data in an EntityStore to be made
@@ -30,16 +29,22 @@ import org.apache.zest.io.Output;
 public interface BackupRestore
 {
     /**
-     * Input that allows data from the entity store to be backed up.
-     *
-     * @return An Input instance containing the data to back up.
+     * Backup as a stream of serialized entity states, must be closed.
+     */
+    Stream<String> backup();
+
+    /**
+     * Restore from a stream of serialized entity states.
      */
-    Input<String, IOException> backup();
+    void restore( Stream<String> states );
 
     /**
-     * Output that allows data to be restored from a backup.
+     * Restore from streams of serialized entity states.
      *
-     * @return An Output instance to receive the restored data.
+     * @return A consumer of streams of serialized entity states
      */
-    Output<String, IOException> restore();
+    default Consumer<Stream<String>> restore()
+    {
+        return this::restore;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java
index 71752b0..2e002c2 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java
@@ -20,9 +20,9 @@
 package org.apache.zest.spi.entitystore;
 
 import java.time.Instant;
+import java.util.stream.Stream;
 import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.api.usecase.Usecase;
-import org.apache.zest.io.Input;
 import org.apache.zest.spi.entity.EntityState;
 
 /**
@@ -32,5 +32,11 @@ public interface EntityStore
 {
     EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecase, Instant currentTime );
 
-    Input<EntityState, EntityStoreException> entityStates( ModuleDescriptor module );
+    /**
+     * Stream of all entity states, must be closed.
+     *
+     * @param module Module
+     * @return Stream of all entity states, must be closed
+     */
+    Stream<EntityState> entityStates( ModuleDescriptor module );
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
index 90d5acb..ebaa2f2 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
@@ -29,6 +29,7 @@ import java.time.Instant;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
+import java.util.stream.Stream;
 import org.apache.zest.api.cache.CacheOptions;
 import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.entity.EntityDescriptor;
@@ -47,10 +48,6 @@ import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.api.unitofwork.NoSuchEntityTypeException;
 import org.apache.zest.api.usecase.Usecase;
 import org.apache.zest.api.value.ValueSerialization;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
 import org.apache.zest.spi.ZestSPI;
 import org.apache.zest.spi.cache.Cache;
 import org.apache.zest.spi.cache.CachePool;
@@ -310,102 +307,62 @@ public class JSONMapEntityStoreMixin
     }
 
     @Override
-    public Input<EntityState, EntityStoreException> entityStates( final ModuleDescriptor module )
+    public Stream<EntityState> entityStates( ModuleDescriptor module )
     {
-        return new Input<EntityState, EntityStoreException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super EntityState, ReceiverThrowableType> output )
-                throws EntityStoreException, ReceiverThrowableType
+        List<EntityState> migrated = new ArrayList<>();
+        return mapEntityStore.entityStates().map(
+            reader ->
             {
-                output.receiveFrom( new Sender<EntityState, EntityStoreException>()
+                EntityState entity = readEntityState( module, reader );
+                if( entity.status() == EntityStatus.UPDATED )
                 {
-                    @Override
-                    public <ReceiverThrowableType extends Throwable> void sendTo( final Receiver<? super EntityState, ReceiverThrowableType> receiver )
-                        throws ReceiverThrowableType, EntityStoreException
+                    migrated.add( entity );
+                    // Synch back 100 at a time
+                    if( migrated.size() > 100 )
                     {
-                        final List<EntityState> migrated = new ArrayList<>();
-                        try
-                        {
-                            mapEntityStore.entityStates().transferTo( new Output<Reader, ReceiverThrowableType>()
-                            {
-                                @Override
-                                public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends Reader, SenderThrowableType> sender )
-                                    throws ReceiverThrowableType, SenderThrowableType
-                                {
-                                    sender.sendTo( new Receiver<Reader, ReceiverThrowableType>()
-                                    {
-                                        @Override
-                                        public void receive( Reader item )
-                                            throws ReceiverThrowableType
-                                        {
-                                            final EntityState entity = readEntityState( module, item );
-                                            if( entity.status() == EntityStatus.UPDATED )
-                                            {
-                                                migrated.add( entity );
-
-                                                // Synch back 100 at a time
-                                                if( migrated.size() > 100 )
-                                                {
-                                                    try
-                                                    {
-                                                        synchMigratedEntities( migrated );
-                                                    }
-                                                    catch( IOException e )
-                                                    {
-                                                        throw new EntityStoreException( "Synchronization of Migrated Entities failed.", e );
-                                                    }
-                                                }
-                                            }
-                                            receiver.receive( entity );
-                                        }
-                                    } );
-
-                                    // Synch any remaining migrated entities
-                                    if( !migrated.isEmpty() )
-                                    {
-                                        try
-                                        {
-                                            synchMigratedEntities( migrated );
-                                        }
-                                        catch( IOException e )
-                                        {
-                                            throw new EntityStoreException( "Synchronization of Migrated Entities failed.", e );
-                                        }
-                                    }
-                                }
-                            } );
-                        }
-                        catch( IOException e )
-                        {
-                            throw new EntityStoreException( e );
-                        }
+                        synchMigratedEntities( migrated );
                     }
-                } );
+                }
+                return entity;
             }
-        };
+        ).onClose(
+            () ->
+            {
+                // Synch any remaining migrated entities
+                if( !migrated.isEmpty() )
+                {
+                    synchMigratedEntities( migrated );
+                }
+            }
+        );
     }
 
     private void synchMigratedEntities( final List<EntityState> migratedEntities )
-        throws IOException
     {
-        mapEntityStore.applyChanges( new MapEntityStore.MapChanges()
+        try
         {
-            @Override
-            public void visitMap( MapEntityStore.MapChanger changer )
-                throws IOException
+            mapEntityStore.applyChanges( new MapEntityStore.MapChanges()
             {
-                for( EntityState migratedEntity : migratedEntities )
+                @Override
+                public void visitMap( MapEntityStore.MapChanger changer )
+                    throws IOException
                 {
-                    JSONEntityState state = (JSONEntityState) migratedEntity;
-                    try (Writer writer = changer.updateEntity( state.entityReference(), state.entityDescriptor() ))
+                    for( EntityState migratedEntity : migratedEntities )
                     {
-                        writeEntityState( state, writer, state.version(), state.lastModified() );
+                        JSONEntityState state = (JSONEntityState) migratedEntity;
+                        try( Writer writer = changer.updateEntity( state.entityReference(), state.entityDescriptor() ) )
+                        {
+                            writeEntityState( state, writer, state.version(), state.lastModified() );
+                        }
                     }
                 }
-            }
-        } );
-        migratedEntities.clear();
+            } );
+            migratedEntities.clear();
+        }
+        catch( IOException ex )
+        {
+            throw new EntityStoreException( "Synchronization of Migrated Entities failed.", ex );
+        }
     }
 
     protected Identity newUnitOfWorkId()

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStore.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStore.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStore.java
index 2ec20a0..435494f 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStore.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStore.java
@@ -22,9 +22,9 @@ package org.apache.zest.spi.entitystore.helpers;
 import java.io.IOException;
 import java.io.Reader;
 import java.io.Writer;
+import java.util.stream.Stream;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.io.Input;
 import org.apache.zest.spi.entitystore.EntityNotFoundException;
 import org.apache.zest.spi.entitystore.EntityStoreException;
 
@@ -42,9 +42,9 @@ public interface MapEntityStore
         throws EntityStoreException;
 
     /**
-     * @return All entities state Readers
+     * @return All entities state Readers, must be closed
      */
-    Input<Reader, IOException> entityStates();
+    Stream<Reader> entityStates();
 
     void applyChanges( MapChanges changes )
         throws IOException;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
index fceae54..8a61ced 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
@@ -28,6 +28,7 @@ import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Stream;
 import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.common.QualifiedName;
 import org.apache.zest.api.entity.EntityDescriptor;
@@ -46,10 +47,6 @@ import org.apache.zest.api.unitofwork.NoSuchEntityTypeException;
 import org.apache.zest.api.usecase.Usecase;
 import org.apache.zest.api.value.ValueSerialization;
 import org.apache.zest.api.value.ValueSerializationException;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
 import org.apache.zest.spi.ZestSPI;
 import org.apache.zest.spi.entity.EntityState;
 import org.apache.zest.spi.entity.EntityStatus;
@@ -200,74 +197,47 @@ public class MapEntityStoreMixin
     }
 
     @Override
-    public Input<EntityState, EntityStoreException> entityStates( final ModuleDescriptor module )
+    public Stream<EntityState> entityStates( final ModuleDescriptor module )
     {
-        return new Input<EntityState, EntityStoreException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super EntityState, ReceiverThrowableType> output )
-                throws EntityStoreException, ReceiverThrowableType
-            {
-                output.receiveFrom( new Sender<EntityState, EntityStoreException>()
-                {
-                    @Override
-                    public <RecThrowableType extends Throwable> void sendTo( final Receiver<? super EntityState, RecThrowableType> receiver )
-                        throws RecThrowableType, EntityStoreException
-                    {
-                        final List<EntityState> migrated = new ArrayList<>();
-                        try
-                        {
-                            mapEntityStore.entityStates().transferTo( new Output<Reader, RecThrowableType>()
-                            {
-                                @Override
-                                public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends Reader, SenderThrowableType> sender )
-                                    throws RecThrowableType, SenderThrowableType
-                                {
-                                    sender.sendTo( item -> {
-                                        final EntityState entity = readEntityState( module, item );
-                                        if( entity.status() == EntityStatus.UPDATED )
-                                        {
-                                            migrated.add( entity );
-
-                                            // Synch back 100 at a time
-                                            if( migrated.size() > 100 )
-                                            {
-                                                try
-                                                {
-                                                    synchMigratedEntities( migrated );
-                                                }
-                                                catch( IOException e )
-                                                {
-                                                    throw new EntityStoreException( "Synchronization of Migrated Entities failed.", e );
-                                                }
-                                            }
-                                        }
-                                        receiver.receive( entity );
-                                    } );
-
-                                    // Synch any remaining migrated entities
-                                    if( !migrated.isEmpty() )
-                                    {
-                                        try
-                                        {
-                                            synchMigratedEntities( migrated );
-                                        }
-                                        catch( IOException e )
-                                        {
-                                            throw new EntityStoreException( "Synchronization of Migrated Entities failed.", e );
-                                        }
-                                    }
-                                }
-                            } );
-                        }
-                        catch( IOException e )
-                        {
-                            throw new EntityStoreException( e );
-                        }
-                    }
-                } );
-            }
-        };
+        List<EntityState> migrated = new ArrayList<>();
+        return mapEntityStore
+            .entityStates()
+            .map( reader ->
+                  {
+                      EntityState entity = readEntityState( module, reader );
+                      if( entity.status() == EntityStatus.UPDATED )
+                      {
+                          migrated.add( entity );
+                          // Synch back 100 at a time
+                          if( migrated.size() > 100 )
+                          {
+                              try
+                              {
+                                  synchMigratedEntities( migrated );
+                              }
+                              catch( IOException e )
+                              {
+                                  throw new EntityStoreException( "Synchronization of Migrated Entities failed.", e );
+                              }
+                          }
+                      }
+                      return entity;
+                  } )
+            .onClose( () ->
+                      {
+                          // Synch any remaining migrated entities
+                          if( !migrated.isEmpty() )
+                          {
+                              try
+                              {
+                                  synchMigratedEntities( migrated );
+                              }
+                              catch( IOException e )
+                              {
+                                  throw new EntityStoreException( "Synchronization of Migrated Entities failed.", e );
+                              }
+                          }
+                      } );
     }
 
     private void synchMigratedEntities( final List<EntityState> migratedEntities )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
index ab05f39..74368ae 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/entity/AbstractEntityStoreTest.java
@@ -31,6 +31,7 @@ import java.time.ZonedDateTime;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Stream;
 import org.apache.zest.api.association.Association;
 import org.apache.zest.api.association.ManyAssociation;
 import org.apache.zest.api.association.NamedAssociation;
@@ -51,6 +52,7 @@ import org.apache.zest.api.value.ValueBuilder;
 import org.apache.zest.api.value.ValueComposite;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.spi.entity.EntityState;
 import org.apache.zest.spi.entitystore.EntityStore;
 import org.apache.zest.test.AbstractZestTest;
 import org.junit.After;
@@ -501,6 +503,36 @@ public abstract class AbstractEntityStoreTest
         }
     }
 
+    @Test
+    public void entityStatesSPI()
+    {
+        EntityStore entityStore = serviceFinder.findService( EntityStore.class ).get();
+
+        try( Stream<EntityState> states = entityStore.entityStates( module ) )
+        {
+            assertThat( states.count(), is( 0L ) );
+        }
+
+        UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork();
+        TestEntity newInstance = createEntity( unitOfWork );
+        unitOfWork.complete();
+
+        try( Stream<EntityState> states = entityStore.entityStates( module ) )
+        {
+            assertThat( states.count(), is( 1L ) );
+        }
+
+        unitOfWork = unitOfWorkFactory.newUnitOfWork();
+        TestEntity instance = unitOfWork.get( newInstance );
+        unitOfWork.remove( instance );
+        unitOfWork.complete();
+
+        try( Stream<EntityState> states = entityStore.entityStates( module ) )
+        {
+            assertThat( states.count(), is( 0L ) );
+        }
+    }
+
     public interface TestEntity
         extends EntityComposite
     {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/FileEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/FileEntityStoreMixin.java b/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/FileEntityStoreMixin.java
index 1ab1c53..500f313 100644
--- a/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/FileEntityStoreMixin.java
+++ b/extensions/entitystore-file/src/main/java/org/apache/zest/entitystore/file/FileEntityStoreMixin.java
@@ -29,16 +29,13 @@ import java.io.Writer;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.StandardCopyOption;
+import java.util.stream.Stream;
 import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.configuration.Configuration;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
 import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
 import org.apache.zest.library.fileconfig.FileConfiguration;
 import org.apache.zest.spi.entitystore.BackupRestore;
 import org.apache.zest.spi.entitystore.EntityAlreadyExistsException;
@@ -231,84 +228,43 @@ public class FileEntityStoreMixin
     }
 
     @Override
-    public Input<String, IOException> backup()
+    public Stream<Reader> entityStates()
     {
-        return new Input<String, IOException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super String, ReceiverThrowableType> output )
-                throws IOException, ReceiverThrowableType
-            {
-                output.receiveFrom( new Sender<String, IOException>()
-                {
-                    @Override
-                    public <ThrowableType extends Throwable> void sendTo( Receiver<? super String, ThrowableType> receiver )
-                        throws ThrowableType, IOException
-                    {
-                        for( File sliceDirectory : dataDirectory.listFiles() )
-                        {
-                            for( File file : sliceDirectory.listFiles() )
-                            {
-                                receiver.receive( fetch( file ) );
-                            }
-                        }
-                    }
-                } );
-            }
-        };
+        return backup().map( StringReader::new );
     }
 
     @Override
-    public Output<String, IOException> restore()
+    public Stream<String> backup()
     {
-        return new Output<String, IOException>()
+        if( !dataDirectory.exists() )
         {
-            @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
-                    {
-                        String id = item.substring( "{\"reference\":\"".length() );
-                        id = id.substring( 0, id.indexOf( '"' ) );
-                        store( getDataFile( id ), item );
-                    }
-                } );
-            }
-        };
+            return Stream.of();
+        }
+        try
+        {
+            return java.nio.file.Files.walk( dataDirectory.toPath(), 3 )
+                                      .skip( 1 )
+                                      .filter( path -> !"slices".equals( path.getFileName().toString() ) )
+                                      .map( Path::toFile )
+                                      .filter( file -> !file.isDirectory() )
+                                      .map( this::uncheckedFetch );
+        }
+        catch( IOException ex )
+        {
+            throw new EntityStoreException( ex );
+        }
     }
 
     @Override
-    public Input<Reader, IOException> entityStates()
+    public void restore( final Stream<String> stream )
     {
-        return new Input<Reader, IOException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super Reader, ReceiverThrowableType> output )
-                throws IOException, ReceiverThrowableType
+        stream.forEach(
+            item ->
             {
-                output.receiveFrom( new Sender<Reader, IOException>()
-                {
-                    @Override
-                    public <ThrowableType extends Throwable> void sendTo( Receiver<? super Reader, ThrowableType> receiver )
-                        throws ThrowableType, IOException
-                    {
-                        for( File sliceDirectory : dataDirectory.listFiles() )
-                        {
-                            for( File file : sliceDirectory.listFiles() )
-                            {
-                                String state = fetch( file );
-                                receiver.receive( new StringReader( state ) );
-                            }
-                        }
-                    }
-                } );
-            }
-        };
+                String id = item.substring( "{\"reference\":\"".length() );
+                id = id.substring( 0, id.indexOf( '"' ) );
+                uncheckedStore( getDataFile( id ), item );
+            } );
     }
 
     private File getDataFile( String identity )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/extensions/entitystore-geode/src/main/java/org/apache/zest/entitystore/geode/GeodeEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-geode/src/main/java/org/apache/zest/entitystore/geode/GeodeEntityStoreMixin.java b/extensions/entitystore-geode/src/main/java/org/apache/zest/entitystore/geode/GeodeEntityStoreMixin.java
index fca8a6b..25a58b7 100644
--- a/extensions/entitystore-geode/src/main/java/org/apache/zest/entitystore/geode/GeodeEntityStoreMixin.java
+++ b/extensions/entitystore-geode/src/main/java/org/apache/zest/entitystore/geode/GeodeEntityStoreMixin.java
@@ -23,8 +23,8 @@ import java.io.Reader;
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.Writer;
-import java.util.Map;
 import java.util.Properties;
+import java.util.stream.Stream;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.Region;
@@ -39,10 +39,6 @@ import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.service.ServiceActivation;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
 import org.apache.zest.spi.entitystore.EntityNotFoundException;
 import org.apache.zest.spi.entitystore.EntityStoreException;
 import org.apache.zest.spi.entitystore.helpers.MapEntityStore;
@@ -197,27 +193,8 @@ public class GeodeEntityStoreMixin
     }
 
     @Override
-    public Input<Reader, IOException> entityStates()
+    public Stream<Reader> entityStates()
     {
-        return new Input<Reader, IOException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super Reader, ReceiverThrowableType> output )
-                    throws IOException, ReceiverThrowableType
-            {
-                output.receiveFrom( new Sender<Reader, IOException>()
-                {
-                    @Override
-                    public <RTT extends Throwable> void sendTo( Receiver<? super Reader, RTT> receiver )
-                            throws RTT, IOException
-                    {
-                        for( Map.Entry<String, String> eachEntry : region.entrySet() )
-                        {
-                            receiver.receive( new StringReader( eachEntry.getValue() ) );
-                        }
-                    }
-                } );
-            }
-        };
+        return region.values().stream().map( StringReader::new );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/extensions/entitystore-hazelcast/src/main/java/org/apache/zest/entitystore/hazelcast/HazelcastEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-hazelcast/src/main/java/org/apache/zest/entitystore/hazelcast/HazelcastEntityStoreMixin.java b/extensions/entitystore-hazelcast/src/main/java/org/apache/zest/entitystore/hazelcast/HazelcastEntityStoreMixin.java
index f588862..34386f2 100644
--- a/extensions/entitystore-hazelcast/src/main/java/org/apache/zest/entitystore/hazelcast/HazelcastEntityStoreMixin.java
+++ b/extensions/entitystore-hazelcast/src/main/java/org/apache/zest/entitystore/hazelcast/HazelcastEntityStoreMixin.java
@@ -30,16 +30,12 @@ import java.io.Reader;
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.Writer;
-import java.util.Map;
+import java.util.stream.Stream;
 import org.apache.zest.api.configuration.Configuration;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.service.ServiceActivation;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
 import org.apache.zest.spi.entitystore.EntityNotFoundException;
 import org.apache.zest.spi.entitystore.EntityStoreException;
 import org.apache.zest.spi.entitystore.helpers.MapEntityStore;
@@ -147,28 +143,9 @@ public class HazelcastEntityStoreMixin
     }
 
     @Override
-    public Input<Reader, IOException> entityStates()
+    public Stream<Reader> entityStates()
     {
-        return new Input<Reader, IOException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super Reader, ReceiverThrowableType> output )
-                throws IOException, ReceiverThrowableType
-            {
-                output.receiveFrom( new Sender<Reader, IOException>()
-                {
-                    @Override
-                    public <RTT extends Throwable> void sendTo( Receiver<? super Reader, RTT> receiver )
-                        throws RTT, IOException
-                    {
-                        for( Map.Entry<String, String> eachEntry : stringMap.entrySet() )
-                        {
-                            receiver.receive( new StringReader( eachEntry.getValue() ) );
-                        }
-                    }
-                } );
-            }
-        };
+        return stringMap.values().stream().map( StringReader::new );
     }
 
     private Config createConfig( HazelcastConfiguration configuration )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/extensions/entitystore-jclouds/src/main/java/org/apache/zest/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/src/main/java/org/apache/zest/entitystore/jclouds/JCloudsMapEntityStoreMixin.java b/extensions/entitystore-jclouds/src/main/java/org/apache/zest/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
index f8c2ac1..b895177 100644
--- a/extensions/entitystore-jclouds/src/main/java/org/apache/zest/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
+++ b/extensions/entitystore-jclouds/src/main/java/org/apache/zest/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
@@ -26,7 +26,6 @@ import com.google.common.collect.Maps;
 import com.google.common.io.ByteSource;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.Reader;
 import java.io.StringReader;
 import java.io.StringWriter;
@@ -36,15 +35,12 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Scanner;
 import java.util.Set;
+import java.util.stream.Stream;
 import org.apache.zest.api.configuration.Configuration;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.service.ServiceActivation;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
 import org.apache.zest.spi.entitystore.EntityNotFoundException;
 import org.apache.zest.spi.entitystore.EntityStoreException;
 import org.apache.zest.spi.entitystore.helpers.MapEntityStore;
@@ -54,7 +50,6 @@ import org.jclouds.apis.Apis;
 import org.jclouds.blobstore.BlobStore;
 import org.jclouds.blobstore.BlobStoreContext;
 import org.jclouds.blobstore.domain.Blob;
-import org.jclouds.blobstore.domain.StorageMetadata;
 import org.jclouds.io.Payload;
 import org.jclouds.providers.ProviderMetadata;
 import org.jclouds.providers.Providers;
@@ -254,52 +249,26 @@ public class JCloudsMapEntityStoreMixin
     }
 
     @Override
-    public Input<Reader, IOException> entityStates()
+    public Stream<Reader> entityStates()
     {
-        return new Input<Reader, IOException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super Reader, ReceiverThrowableType> output )
-                throws IOException, ReceiverThrowableType
-            {
-                output.receiveFrom(
-                    new Sender<Reader, IOException>()
-                    {
-                        @Override
-                        public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super Reader, ReceiverThrowableType> receiver )
-                            throws ReceiverThrowableType, IOException
-                        {
-                            for( StorageMetadata stored : storeContext.getBlobStore().list() )
-                            {
-                                Payload payload = storeContext.getBlobStore().getBlob( container, stored.getName() ).getPayload();
-                                if( payload == null )
-                                {
-                                    throw new EntityNotFoundException( EntityReference.parseEntityReference( stored.getName() ) );
-                                }
-                                InputStream input = null;
-                                try
-                                {
-                                    input = payload.openStream();
-                                    receiver.receive( new InputStreamReader( input, "UTF-8" ) );
-                                }
-                                finally
-                                {
-                                    if( input != null )
-                                    {
-                                        try
-                                        {
-                                            input.close();
-                                        }
-                                        catch( IOException ignored )
-                                        {
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                );
-            }
-        };
+        return storeContext
+            .getBlobStore().list( container ).stream()
+            .map( metadata ->
+                  {
+                      Payload payload = storeContext.getBlobStore().getBlob( container, metadata.getName() ).getPayload();
+                      if( payload == null )
+                      {
+                          throw new EntityNotFoundException( EntityReference.parseEntityReference( metadata.getName() ) );
+                      }
+                      try( InputStream input = payload.openStream() )
+                      {
+                          String state = new Scanner( input, UTF_8.name() ).useDelimiter( "\\Z" ).next();
+                          return (Reader) new StringReader( state );
+                      }
+                      catch( IOException ex )
+                      {
+                          throw new EntityStoreException( ex );
+                      }
+                  } );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreMixin.java b/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreMixin.java
index fe3a9cf..19c2b7d 100644
--- a/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreMixin.java
+++ b/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreMixin.java
@@ -24,9 +24,16 @@ import java.io.IOException;
 import java.io.Reader;
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.io.UncheckedIOException;
 import java.io.Writer;
 import java.util.Properties;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.locks.ReadWriteLock;
+import java.util.function.Consumer;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
 import jdbm.RecordManager;
 import jdbm.RecordManagerFactory;
 import jdbm.RecordManagerOptions;
@@ -48,10 +55,6 @@ import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.injection.scope.Uses;
 import org.apache.zest.api.service.ServiceDescriptor;
 import org.apache.zest.io.Files;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
 import org.apache.zest.library.fileconfig.FileConfiguration;
 import org.apache.zest.library.locking.ReadLock;
 import org.apache.zest.library.locking.WriteLock;
@@ -213,198 +216,166 @@ public class JdbmEntityStoreMixin
     }
 
     @Override
-    public Input<Reader, IOException> entityStates()
+    public Stream<Reader> entityStates()
     {
-        return new Input<Reader, IOException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super Reader, ReceiverThrowableType> output )
-                throws IOException, ReceiverThrowableType
-            {
-                lock.writeLock().lock();
-
-                try
-                {
-                    output.receiveFrom( new Sender<Reader, IOException>()
-                    {
-                        @Override
-                        public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super Reader, ReceiverThrowableType> receiver )
-                            throws ReceiverThrowableType, IOException
-                        {
-                            final TupleBrowser browser = index.browse();
-                            final Tuple tuple = new Tuple();
-
-                            while( browser.getNext( tuple ) )
-                            {
-                                Identity id = new StringIdentity( (byte[]) tuple.getKey() );
-
-                                Long stateIndex = getStateIndex( id );
-
-                                if( stateIndex == null )
-                                {
-                                    continue;
-                                } // Skip this one
-
-                                byte[] serializedState = (byte[]) recordManager.fetch( stateIndex, serializer );
-
-                                receiver.receive( new StringReader( new String( serializedState, "UTF-8" ) ) );
-                            }
-                        }
-                    } );
-                }
-                finally
-                {
-                    lock.writeLock().unlock();
-                }
-            }
-        };
+        return backup().map( StringReader::new );
     }
 
     @Override
-    public Input<String, IOException> backup()
+    public Stream<String> backup()
     {
-        return new Input<String, IOException>()
+        lock.writeLock().lock();
+        TupleBrowser browser;
+        try
         {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super String, ReceiverThrowableType> output )
-                throws IOException, ReceiverThrowableType
+            browser = index.browse();
+        }
+        catch( IOException ex )
+        {
+            lock.writeLock().unlock();
+            throw new EntityStoreException( ex );
+        }
+        return StreamSupport.stream(
+            new Spliterators.AbstractSpliterator<String>( Long.MAX_VALUE, Spliterator.ORDERED )
             {
-                lock.readLock().lock();
+                private final Tuple tuple = new Tuple();
 
-                try
+                @Override
+                public boolean tryAdvance( final Consumer<? super String> action )
                 {
-                    output.receiveFrom( new Sender<String, IOException>()
+                    try
                     {
-                        @Override
-                        public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super String, ReceiverThrowableType> receiver )
-                            throws ReceiverThrowableType, IOException
+                        if( !browser.getNext( tuple ) )
                         {
-                            final TupleBrowser browser = index.browse();
-                            final Tuple tuple = new Tuple();
-
-                            while( browser.getNext( tuple ) )
-                            {
-                                String id = new String( (byte[]) tuple.getKey(), "UTF-8" );
-
-                                Long stateIndex = getStateIndex( new StringIdentity( id ) );
-
-                                if( stateIndex == null )
-                                {
-                                    continue;
-                                } // Skip this one
-
-                                byte[] serializedState = (byte[]) recordManager.fetch( stateIndex, serializer );
-
-                                receiver.receive( new String( serializedState, "UTF-8" ) );
-                            }
+                            return false;
                         }
-                    } );
-                }
-                finally
-                {
-                    lock.readLock().unlock();
+                        Identity identity = new StringIdentity( (byte[]) tuple.getKey() );
+                        Long stateIndex = getStateIndex( identity );
+                        if( stateIndex == null )
+                        {
+                            return false;
+                        }
+                        byte[] serializedState = (byte[]) recordManager.fetch( stateIndex, serializer );
+                        String state = new String( serializedState, "UTF-8" );
+                        action.accept( state );
+                        return true;
+                    }
+                    catch( IOException ex )
+                    {
+                        lock.writeLock().unlock();
+                        throw new EntityStoreException( ex );
+                    }
                 }
-            }
-        };
+            },
+            false
+        ).onClose( () -> lock.writeLock().unlock() );
     }
 
     @Override
-    public Output<String, IOException> restore()
+    public void restore( final Stream<String> states )
     {
-        return new Output<String, IOException>()
+        File dbFile = new File( getDatabaseName() + ".db" );
+        File lgFile = new File( getDatabaseName() + ".lg" );
+
+        // Create temporary store
+        File tempDatabase = Files.createTemporayFileOf( dbFile );
+        final RecordManager recordManager;
+        final BTree index;
+        try
+        {
+            recordManager = RecordManagerFactory.createRecordManager( tempDatabase.getAbsolutePath(),
+                                                                      new Properties() );
+            ByteArrayComparator comparator = new ByteArrayComparator();
+            index = BTree.createInstance( recordManager, comparator, serializer, DefaultSerializer.INSTANCE, 16 );
+            recordManager.setNamedObject( "index", index.getRecid() );
+            recordManager.commit();
+        }
+        catch( IOException ex )
+        {
+            throw new EntityStoreException( ex );
+        }
+        try
         {
-            @Override
-            public <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends String, SenderThrowableType> sender )
-                throws IOException, SenderThrowableType
+            // TODO NO NEED TO SYNCHRONIZE HERE
+            AtomicLong counter = new AtomicLong();
+            Consumer<String> stateConsumer = state ->
             {
-                File dbFile = new File( getDatabaseName() + ".db" );
-                File lgFile = new File( getDatabaseName() + ".lg" );
-
-                // Create temporary store
-                File tempDatabase = Files.createTemporayFileOf( dbFile );
-
-                final RecordManager recordManager = RecordManagerFactory.createRecordManager( tempDatabase.getAbsolutePath(), new Properties() );
-                ByteArrayComparator comparator = new ByteArrayComparator();
-                final BTree index = BTree.createInstance( recordManager, comparator, serializer, DefaultSerializer.INSTANCE, 16 );
-                recordManager.setNamedObject( "index", index.getRecid() );
-                recordManager.commit();
-
                 try
                 {
-                    sender.sendTo( new Receiver<String, IOException>()
+                    // Commit one batch
+                    if( ( counter.incrementAndGet() % 1000 ) == 0 )
                     {
-                        int counter = 0;
-
-                        @Override
-                        public void receive( String item )
-                            throws IOException
-                        {
-                            // Commit one batch
-                            if( ( counter++ % 1000 ) == 0 )
-                            {
-                                recordManager.commit();
-                            }
+                        recordManager.commit();
+                    }
 
-                            String id = item.substring( "{\"reference\":\"".length() );
-                            id = id.substring( 0, id.indexOf( '"' ) );
+                    String id = state.substring( "{\"reference\":\"".length() );
+                    id = id.substring( 0, id.indexOf( '"' ) );
 
-                            // Insert
-                            byte[] stateArray = item.getBytes( "UTF-8" );
-                            long stateIndex = recordManager.insert( stateArray, serializer );
-                            index.insert( id.getBytes( "UTF-8" ), stateIndex, false );
-                        }
-                    } );
+                    // Insert
+                    byte[] stateArray = state.getBytes( "UTF-8" );
+                    long stateIndex = recordManager.insert( stateArray, serializer );
+                    index.insert( id.getBytes( "UTF-8" ), stateIndex, false );
                 }
-                catch( IOException e )
+                catch( IOException ex )
                 {
-                    recordManager.close();
-                    tempDatabase.delete();
-                    throw e;
+                    throw new UncheckedIOException( ex );
                 }
-                catch( Throwable senderThrowableType )
-                {
-                    recordManager.close();
-                    tempDatabase.delete();
-                    throw (SenderThrowableType) senderThrowableType;
-                }
-
-                // Import went ok - continue
-                recordManager.commit();
-                // close file handles otherwise Microsoft Windows will fail to rename database files.
+            };
+            states.forEach( stateConsumer );
+            // Import went ok - continue
+            recordManager.commit();
+            // close file handles otherwise Microsoft Windows will fail to rename database files.
+            recordManager.close();
+        }
+        catch( IOException | UncheckedIOException ex )
+        {
+            try
+            {
                 recordManager.close();
+            }
+            catch( IOException ignore ) { }
+            tempDatabase.delete();
+            throw new EntityStoreException( ex );
+        }
+        try
+        {
 
-                lock.writeLock().lock();
-                try
-                {
-                    // Replace old database with new
-                    JdbmEntityStoreMixin.this.recordManager.close();
-
-                    boolean deletedOldDatabase = true;
-                    deletedOldDatabase &= dbFile.delete();
-                    deletedOldDatabase &= lgFile.delete();
-                    if( !deletedOldDatabase )
-                    {
-                        throw new IOException( "Could not remove old database" );
-                    }
+            lock.writeLock().lock();
+            try
+            {
+                // Replace old database with new
+                JdbmEntityStoreMixin.this.recordManager.close();
 
-                    boolean renamedTempDatabase = true;
-                    renamedTempDatabase &= new File( tempDatabase.getAbsolutePath() + ".db" ).renameTo( dbFile );
-                    renamedTempDatabase &= new File( tempDatabase.getAbsolutePath() + ".lg" ).renameTo( lgFile );
+                boolean deletedOldDatabase = true;
+                deletedOldDatabase &= dbFile.delete();
+                deletedOldDatabase &= lgFile.delete();
+                if( !deletedOldDatabase )
+                {
+                    throw new EntityStoreException( "Could not remove old database" );
+                }
 
-                    if( !renamedTempDatabase )
-                    {
-                        throw new IOException( "Could not replace database with temp database" );
-                    }
+                boolean renamedTempDatabase = true;
+                renamedTempDatabase &= new File( tempDatabase.getAbsolutePath() + ".db" ).renameTo( dbFile );
+                renamedTempDatabase &= new File( tempDatabase.getAbsolutePath() + ".lg" ).renameTo( lgFile );
 
-                    // Start up again
-                    initialize();
-                }
-                finally
+                if( !renamedTempDatabase )
                 {
-                    lock.writeLock().unlock();
+                    throw new EntityStoreException( "Could not replace database with temp database" );
                 }
+
+                // Start up again
+                initialize();
             }
-        };
+            finally
+            {
+                lock.writeLock().unlock();
+            }
+        }
+        catch( IOException ex )
+        {
+            tempDatabase.delete();
+            throw new EntityStoreException( ex );
+        }
     }
 
     private String getDatabaseName()

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/extensions/entitystore-leveldb/src/main/java/org/apache/zest/entitystore/leveldb/LevelDBEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-leveldb/src/main/java/org/apache/zest/entitystore/leveldb/LevelDBEntityStoreMixin.java b/extensions/entitystore-leveldb/src/main/java/org/apache/zest/entitystore/leveldb/LevelDBEntityStoreMixin.java
index 638b021..7e485b2 100644
--- a/extensions/entitystore-leveldb/src/main/java/org/apache/zest/entitystore/leveldb/LevelDBEntityStoreMixin.java
+++ b/extensions/entitystore-leveldb/src/main/java/org/apache/zest/entitystore/leveldb/LevelDBEntityStoreMixin.java
@@ -26,6 +26,11 @@ import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.Writer;
 import java.nio.charset.Charset;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.function.Consumer;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
 import org.apache.zest.api.configuration.Configuration;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
@@ -34,10 +39,6 @@ import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.injection.scope.Uses;
 import org.apache.zest.api.service.ServiceActivation;
 import org.apache.zest.api.service.ServiceDescriptor;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
 import org.apache.zest.library.fileconfig.FileConfiguration;
 import org.apache.zest.spi.entitystore.EntityNotFoundException;
 import org.apache.zest.spi.entitystore.EntityStoreException;
@@ -197,42 +198,38 @@ public class LevelDBEntityStoreMixin
     }
 
     @Override
-    public Input<Reader, IOException> entityStates()
+    public Stream<Reader> entityStates()
     {
-        return new Input<Reader, IOException>()
-        {
-
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super Reader, ReceiverThrowableType> output )
-                throws IOException, ReceiverThrowableType
+        DBIterator iterator = db.iterator();
+        iterator.seekToFirst();
+        return StreamSupport.stream(
+            new Spliterators.AbstractSpliterator<Reader>( Long.MAX_VALUE, Spliterator.ORDERED )
             {
-                output.receiveFrom( new Sender<Reader, IOException>()
+                @Override
+                public boolean tryAdvance( final Consumer<? super Reader> action )
                 {
-
-                    @Override
-                    public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super Reader, ReceiverThrowableType> receiver )
-                        throws ReceiverThrowableType, IOException
+                    if( !iterator.hasNext() )
                     {
-                        DBIterator iterator = db.iterator();
-                        try
-                        {
-                            for( iterator.seekToFirst(); iterator.hasNext(); iterator.next() )
-                            {
-                                byte[] state = iterator.peekNext().getValue();
-                                String jsonState = new String( state, charset );
-                                receiver.receive( new StringReader( jsonState ) );
-                            }
-                        }
-                        finally
-                        {
-                            iterator.close();
-                        }
+                        return false;
                     }
-
-                } );
+                    action.accept( new StringReader( new String( iterator.next().getValue(), charset ) ) );
+                    return true;
+                }
+            },
+            false
+        ).onClose(
+            () ->
+            {
+                try
+                {
+                    iterator.close();
+                }
+                catch( IOException ex )
+                {
+                    throw new EntityStoreException( "Unable to close DB iterator" );
+                }
             }
-
-        };
+        );
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/extensions/entitystore-mongodb/src/main/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-mongodb/src/main/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreMixin.java b/extensions/entitystore-mongodb/src/main/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreMixin.java
index 9b988f5..ee97171 100644
--- a/extensions/entitystore-mongodb/src/main/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreMixin.java
+++ b/extensions/entitystore-mongodb/src/main/java/org/apache/zest/entitystore/mongodb/MongoMapEntityStoreMixin.java
@@ -25,7 +25,6 @@ import com.mongodb.MongoClientOptions;
 import com.mongodb.MongoCredential;
 import com.mongodb.ServerAddress;
 import com.mongodb.WriteConcern;
-import com.mongodb.client.FindIterable;
 import com.mongodb.client.MongoCollection;
 import com.mongodb.client.MongoCursor;
 import com.mongodb.client.MongoDatabase;
@@ -40,15 +39,13 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
 import org.apache.zest.api.configuration.Configuration;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.service.ServiceActivation;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
 import org.apache.zest.spi.entitystore.EntityNotFoundException;
 import org.apache.zest.spi.entitystore.EntityStoreException;
 import org.apache.zest.spi.entitystore.helpers.MapEntityStore;
@@ -289,33 +286,16 @@ public class MongoMapEntityStoreMixin
     }
 
     @Override
-    public Input<Reader, IOException> entityStates()
+    public Stream<Reader> entityStates()
     {
-        return new Input<Reader, IOException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo(
-                Output<? super Reader, ReceiverThrowableType> output )
-                throws IOException, ReceiverThrowableType
-            {
-                output.receiveFrom( new Sender<Reader, IOException>()
-                {
-                    @Override
-                    public <ReceiverThrowableType extends Throwable> void sendTo(
-                        Receiver<? super Reader, ReceiverThrowableType> receiver )
-                        throws ReceiverThrowableType, IOException
-                    {
-                        FindIterable<Document> cursor = db.getCollection( collectionName ).find();
-                        for( Document eachEntity : cursor )
-                        {
-                            Document bsonState = (Document) eachEntity.get( STATE_COLUMN );
-                            String jsonState = JSON.serialize( bsonState );
-                            receiver.receive( new StringReader( jsonState ) );
-                        }
-                    }
-                } );
-            }
-        };
+        return StreamSupport
+            .stream( db.getCollection( collectionName ).find().spliterator(), false )
+            .map( eachEntity ->
+                  {
+                      Document bsonState = (Document) eachEntity.get( STATE_COLUMN );
+                      String jsonState = JSON.serialize( bsonState );
+                      return new StringReader( jsonState );
+                  } );
     }
 
     private Bson byIdentity( EntityReference entityReference )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
index f76f8d3..09918a2 100644
--- a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
+++ b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
@@ -29,6 +29,7 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.prefs.BackingStoreException;
 import java.util.prefs.Preferences;
+import java.util.stream.Stream;
 import org.apache.zest.api.cache.CacheOptions;
 import org.apache.zest.api.common.QualifiedName;
 import org.apache.zest.api.entity.EntityDescriptor;
@@ -57,10 +58,6 @@ import org.apache.zest.api.usecase.Usecase;
 import org.apache.zest.api.usecase.UsecaseBuilder;
 import org.apache.zest.api.value.ValueSerialization;
 import org.apache.zest.api.value.ValueSerializationException;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
 import org.apache.zest.spi.ZestSPI;
 import org.apache.zest.spi.entity.EntityState;
 import org.apache.zest.spi.entity.EntityStatus;
@@ -175,43 +172,23 @@ public class PreferencesEntityStoreMixin
     }
 
     @Override
-    public Input<EntityState, EntityStoreException> entityStates( final ModuleDescriptor module )
+    public Stream<EntityState> entityStates( final ModuleDescriptor module )
     {
-        return new Input<EntityState, EntityStoreException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super EntityState, ReceiverThrowableType> output )
-                throws EntityStoreException, ReceiverThrowableType
-            {
-                output.receiveFrom( new Sender<EntityState, EntityStoreException>()
-                {
-                    @Override
-                    public <RecThrowableType extends Throwable> void sendTo( Receiver<? super EntityState, RecThrowableType> receiver )
-                        throws RecThrowableType, EntityStoreException
-                    {
-                        UsecaseBuilder builder = UsecaseBuilder.buildUsecase( "zest.entitystore.preferences.visit" );
-                        Usecase visitUsecase = builder.withMetaInfo( CacheOptions.NEVER ).newUsecase();
-                        final EntityStoreUnitOfWork uow =
-                            newUnitOfWork( module, visitUsecase, SystemTime.now() );
+        UsecaseBuilder builder = UsecaseBuilder.buildUsecase( "zest.entitystore.preferences.visit" );
+        Usecase visitUsecase = builder.withMetaInfo( CacheOptions.NEVER ).newUsecase();
+        EntityStoreUnitOfWork uow = newUnitOfWork( module, visitUsecase, SystemTime.now() );
 
-                        try
-                        {
-                            String[] identities = root.childrenNames();
-                            for( String identity : identities )
-                            {
-                                EntityReference reference = EntityReference.parseEntityReference( identity );
-                                EntityState entityState = uow.entityStateOf( module, reference );
-                                receiver.receive( entityState );
-                            }
-                        }
-                        catch( BackingStoreException e )
-                        {
-                            throw new EntityStoreException( e );
-                        }
-                    }
-                } );
-            }
-        };
+        try
+        {
+            return Stream.of( root.childrenNames() )
+                         .map( EntityReference::parseEntityReference )
+                         .map( ref -> uow.entityStateOf( module, ref ) )
+                         .onClose( uow::discard );
+        }
+        catch( BackingStoreException e )
+        {
+            throw new EntityStoreException( e );
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/extensions/entitystore-redis/src/main/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-redis/src/main/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreMixin.java b/extensions/entitystore-redis/src/main/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreMixin.java
index 4113e39..9bc2446 100644
--- a/extensions/entitystore-redis/src/main/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreMixin.java
+++ b/extensions/entitystore-redis/src/main/java/org/apache/zest/entitystore/redis/RedisMapEntityStoreMixin.java
@@ -24,16 +24,12 @@ import java.io.Reader;
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.Writer;
-import java.util.Set;
+import java.util.stream.Stream;
 import org.apache.zest.api.configuration.Configuration;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.service.ServiceActivation;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
 import org.apache.zest.spi.entitystore.EntityAlreadyExistsException;
 import org.apache.zest.spi.entitystore.EntityNotFoundException;
 import org.apache.zest.spi.entitystore.EntityStoreException;
@@ -164,38 +160,12 @@ public class RedisMapEntityStoreMixin
     }
 
     @Override
-    public Input<Reader, IOException> entityStates()
+    public Stream<Reader> entityStates()
     {
-        return new Input<Reader, IOException>()
-        {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super Reader, ReceiverThrowableType> output )
-                throws IOException, ReceiverThrowableType
-            {
-                output.receiveFrom( new Sender<Reader, IOException>()
-                {
-                    @Override
-                    public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super Reader, ReceiverThrowableType> receiver )
-                        throws ReceiverThrowableType, IOException
-                    {
-                        Jedis jedis = pool.getResource();
-                        try
-                        {
-                            Set<String> keys = jedis.keys( "*" );
-                            for( String key : keys )
-                            {
-                                String jsonState = jedis.get( key );
-                                receiver.receive( new StringReader( jsonState ) );
-                            }
-                        }
-                        finally
-                        {
-                            pool.returnResource( jedis );
-                        }
-                    }
-                } );
-            }
-        };
+        Jedis jedis = pool.getResource();
+        return jedis.keys( "*" ).stream()
+                    .map( key -> (Reader) new StringReader( jedis.get( key ) ) )
+                    .onClose( jedis::close );
     }
 
     private static boolean notFound( String jsonState )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/ee1d1abc/extensions/entitystore-riak/src/main/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-riak/src/main/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreMixin.java b/extensions/entitystore-riak/src/main/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreMixin.java
index 0160dfa..fcda8fa 100644
--- a/extensions/entitystore-riak/src/main/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreMixin.java
+++ b/extensions/entitystore-riak/src/main/java/org/apache/zest/entitystore/riak/RiakMapEntityStoreMixin.java
@@ -28,20 +28,6 @@ import com.basho.riak.client.core.RiakNode;
 import com.basho.riak.client.core.query.Location;
 import com.basho.riak.client.core.query.Namespace;
 import com.basho.riak.client.core.util.HostAndPort;
-import org.apache.zest.api.common.InvalidApplicationException;
-import org.apache.zest.api.configuration.Configuration;
-import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.api.entity.EntityReference;
-import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.api.service.ServiceActivation;
-import org.apache.zest.io.Input;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
-import org.apache.zest.spi.entitystore.EntityNotFoundException;
-import org.apache.zest.spi.entitystore.EntityStoreException;
-import org.apache.zest.spi.entitystore.helpers.MapEntityStore;
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -57,6 +43,17 @@ import java.security.Security;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
+import org.apache.zest.api.common.InvalidApplicationException;
+import org.apache.zest.api.configuration.Configuration;
+import org.apache.zest.api.entity.EntityDescriptor;
+import org.apache.zest.api.entity.EntityReference;
+import org.apache.zest.api.injection.scope.This;
+import org.apache.zest.api.service.ServiceActivation;
+import org.apache.zest.spi.entitystore.EntityNotFoundException;
+import org.apache.zest.spi.entitystore.EntityStoreException;
+import org.apache.zest.spi.entitystore.helpers.MapEntityStore;
 
 /**
  * Riak Protobuf implementation of MapEntityStore.
@@ -334,40 +331,33 @@ public class RiakMapEntityStoreMixin implements ServiceActivation, MapEntityStor
     }
 
     @Override
-    public Input<Reader, IOException> entityStates()
+    public Stream<Reader> entityStates()
     {
-        return new Input<Reader, IOException>()
+        try
         {
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super Reader, ReceiverThrowableType> output )
-                    throws IOException, ReceiverThrowableType
-            {
-                output.receiveFrom( new Sender<Reader, IOException>()
-                {
-                    @Override
-                    public <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super Reader, ReceiverThrowableType> receiver )
-                            throws ReceiverThrowableType, IOException
-                    {
-                        try
-                        {
-                            ListKeys listKeys = new ListKeys.Builder( namespace ).build();
-                            ListKeys.Response listKeysResponse = riakClient.execute( listKeys );
-                            for( Location location : listKeysResponse )
-                            {
-                                FetchValue fetch = new FetchValue.Builder( location ).build();
-                                FetchValue.Response response = riakClient.execute( fetch );
-                                String jsonState = response.getValue( String.class );
-                                receiver.receive( new StringReader( jsonState ) );
-                            }
-                        }
-                        catch( InterruptedException | ExecutionException ex )
-                        {
-                            throw new EntityStoreException( "Unable to apply entity changes.", ex );
-                        }
-                    }
-                } );
-            }
-        };
+            ListKeys listKeys = new ListKeys.Builder( namespace ).build();
+            ListKeys.Response listKeysResponse = riakClient.execute( listKeys );
+            return StreamSupport
+                .stream( listKeysResponse.spliterator(), false )
+                .map( location ->
+                      {
+                          try
+                          {
+                              FetchValue fetch = new FetchValue.Builder( location ).build();
+                              FetchValue.Response response = riakClient.execute( fetch );
+                              String jsonState = response.getValue( String.class );
+                              return new StringReader( jsonState );
+                          }
+                          catch( InterruptedException | ExecutionException ex )
+                          {
+                              throw new EntityStoreException( "Unable to get entity states.", ex );
+                          }
+                      } );
+        }
+        catch( InterruptedException | ExecutionException ex )
+        {
+            throw new EntityStoreException( "Unable to get entity states.", ex );
+        }
     }
 
 


[3/7] zest-java git commit: jdbm-entitystore: remove last usage of core/io

Posted by pa...@apache.org.
jdbm-entitystore: remove last usage of core/io


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

Branch: refs/heads/develop
Commit: 888e429210844c4245db0c72e952762ce415e6a7
Parents: ee1d1ab
Author: Paul Merlin <pa...@apache.org>
Authored: Fri Dec 9 09:46:28 2016 +0100
Committer: Paul Merlin <pa...@apache.org>
Committed: Fri Dec 9 09:46:28 2016 +0100

----------------------------------------------------------------------
 .../entitystore/jdbm/JdbmEntityStoreMixin.java  | 39 +++++++++++++++++++-
 1 file changed, 37 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/888e4292/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreMixin.java b/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreMixin.java
index 19c2b7d..5d3d069 100644
--- a/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreMixin.java
+++ b/extensions/entitystore-jdbm/src/main/java/org/apache/zest/entitystore/jdbm/JdbmEntityStoreMixin.java
@@ -26,6 +26,7 @@ import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.UncheckedIOException;
 import java.io.Writer;
+import java.nio.file.Files;
 import java.util.Properties;
 import java.util.Spliterator;
 import java.util.Spliterators;
@@ -54,7 +55,6 @@ import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.injection.scope.Uses;
 import org.apache.zest.api.service.ServiceDescriptor;
-import org.apache.zest.io.Files;
 import org.apache.zest.library.fileconfig.FileConfiguration;
 import org.apache.zest.library.locking.ReadLock;
 import org.apache.zest.library.locking.WriteLock;
@@ -82,6 +82,7 @@ public class JdbmEntityStoreMixin
     private RecordManager recordManager;
     private BTree index;
     private Serializer serializer;
+    private File tempDirectory;
 
     @This
     ReadWriteLock lock;
@@ -278,7 +279,7 @@ public class JdbmEntityStoreMixin
         File lgFile = new File( getDatabaseName() + ".lg" );
 
         // Create temporary store
-        File tempDatabase = Files.createTemporayFileOf( dbFile );
+        File tempDatabase = createTemporaryDatabase();
         final RecordManager recordManager;
         final BTree index;
         try
@@ -401,6 +402,40 @@ public class JdbmEntityStoreMixin
         return name;
     }
 
+    private File createTemporaryDatabase()
+    {
+        try
+        {
+            File tempDatabase = Files.createTempFile( getTemporaryDirectory().toPath(),
+                                                      descriptor.identity().toString(),
+                                                      "write" ).toFile();
+            tempDatabase.deleteOnExit();
+            return tempDatabase;
+        }
+        catch( IOException ex )
+        {
+            throw new UncheckedIOException( ex );
+        }
+    }
+
+    private File getTemporaryDirectory() throws IOException
+    {
+        if( tempDirectory != null )
+        {
+            return tempDirectory;
+        }
+        String storeId = descriptor.identity().toString();
+        tempDirectory = fileConfiguration != null
+                        ? new File( fileConfiguration.temporaryDirectory(), storeId )
+                        : new File( new File( System.getProperty( "java.io.tmpdir" ) ),
+                                    storeId );
+        if( !tempDirectory.exists() )
+        {
+            java.nio.file.Files.createDirectories( tempDirectory.toPath() );
+        }
+        return tempDirectory;
+    }
+
     private Properties getProperties()
     {
         JdbmConfiguration config = this.config.get();


[4/7] zest-java git commit: Remove core/io

Posted by pa...@apache.org.
http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/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 9cec3c5..0000000
--- a/core/io/src/main/java/org/apache/zest/io/Transforms.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.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.function.Function;
-import java.util.function.Predicate;
-import java.util.logging.Logger;
-
-/**
- * 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 Predicate<? 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.test( 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.apply( 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 Predicate<? 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.test( item ) )
-                                {
-                                    receiver.receive( function.apply( 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 apply( 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[] apply( 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 apply( 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 apply( 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 apply( 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 apply( T t )
-        {
-            counter.apply( 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.apply( counter.count + "" );
-            }
-        }
-    }
-    // END SNIPPET: progress
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/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 67d12b4..0000000
--- a/core/io/src/main/java/org/apache/zest/io/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>I/O API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/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 28d52b0..0000000
--- a/core/io/src/test/java/org/apache/zest/io/InputOutputTest.java
+++ /dev/null
@@ -1,386 +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.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.function.Function;
-import java.util.logging.Logger;
-import org.hamcrest.CoreMatchers;
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.zest.functional.Visitor;
-
-import static java.util.Arrays.asList;
-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( Arrays.asList( data ) ).transferTo(
-            Transforms.map(
-                new Transforms.ProgressLog<>(
-                    Logger.getLogger( InputOutputTest.class.getName() ), "Data transferred: {0}", 10 ),
-                Outputs.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 apply( 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 apply( 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/37ce367a/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 d360387..0000000
--- a/core/io/src/test/java/org/apache/zest/io/docsupport/IoDocs.java
+++ /dev/null
@@ -1,54 +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
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/core/io/src/test/resources/iotest.txt
----------------------------------------------------------------------
diff --git a/core/io/src/test/resources/iotest.txt b/core/io/src/test/resources/iotest.txt
deleted file mode 100644
index a6d84a8..0000000
--- a/core/io/src/test/resources/iotest.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Test
-of transfer
-from input
-to output

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/manual/src/docs/tutorials/howto-use-io.txt
----------------------------------------------------------------------
diff --git a/manual/src/docs/tutorials/howto-use-io.txt b/manual/src/docs/tutorials/howto-use-io.txt
deleted file mode 100644
index af22317..0000000
--- a/manual/src/docs/tutorials/howto-use-io.txt
+++ /dev/null
@@ -1,329 +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.
-//////////////////////
-
-[[howto-use-io,Use I/O API]]
-= Use I/O API =
-
-NOTE: This article was written on Rickard �berg's blog, 6 Nov 2010
-
-
-The past week I've had to deal with a lot of data shuffling, both in raw form as bytes and strings, and as SPI and
-domain level objects. What struck me is that it is notoriously hard to shuffle things from one place to another in a
-way that is scalable, performant and handles errors correctly. And I had to do some things over and over again, like
-reading strings from files.
-
-So the thought occurred: there must be a general pattern to how this thing works, which can be extracted and put into a
-library. "Reading lines from a text file" should only have to be done once, and then used in whatever scenario requires
-it. Let's take a look at a typical example of reading from one file and writing to another to see if we can find out
-what the possible pieces could be:
-
-[source,java]
--------------
-1: File source = new File( getClass().getResource( "/iotest.txt" ).getFile() );
-1: File destination = File.createTempFile( "test", ".txt" );
-1: destination.deleteOnExit();
-2: BufferedReader reader = new BufferedReader(new FileReader(source));
-3: long count = 0;
-2: try
-2: {
-4:    BufferedWriter writer = new BufferedWriter(new FileWriter(destination));
-4:    try
-4:    {
-2:        String line = null;
-2:        while ((line = reader.readLine()) != null)
-2:        {
-3:            count++;
-4:            writer.append( line ).append( '\n' );
-2:        }
-4:        writer.close();
-4:    } catch (IOException e)
-4:    {
-4:        writer.close();
-4:        destination.delete();
-4:    }
-2: } finally
-2: {
-2:     reader.close();
-2: }
-1: System.out.println(count)
--------------
-
-As the numbers to the left indicates, I've identified four parts in this type of code that could be separated from
-each other.
-
-1) is the client code that initiates a transfer, and which have to know the input and output source.
-
-2) is the code that reads lines from an input.
-
-3) is helper code that I use to keep track of what's going on, and which I'd like to reuse no matter what kind of
-transfer is being done.
-
-4) receives the data and writes it down. In this code, if I wanted to implement batching on the read and write side I
-could do so by changing the 2 and 4 parts to read/write multiple lines at a time.
-
-== The API ==
-
-If you want to reproduce what's explained in this tutorial, remember to depend on the Core Runtime artifact that depends
-on Core API, Core SPI, Core Bootstrap and Core Functional & I/O APIs:
-
-include::../../../../core/runtime/build/docs/buildinfo/artifact.txt[]
-
-See the <<howto-depend-on-zest>> tutorial for details.
-
-Once theses parts were identified it was mostly just a matter of putting interfaces on these pieces, and making sure
-they can be easily used in many different situations. The result is as follows.
-
-To start with we have Input:
-
-[snippet,java]
---------------
-source=core/io/src/main/java/org/apache/zest/io/Input.java
-tag=input
--------------
-
-Inputs, like Iterables, can be used over and over again to initiate transfers of data from one place to another, in
-this case an Output. Since I want this to be generic the type of things that is sent is T, so can be anything
-(byte[], String, EntityState, MyDomainObject). I also want the sender and receiver of data to be able to throw their
-own exceptions, and this is marked by declaring these as generic exception types. For example, the input may want to
-throw SQLException and the output IOException, if anything goes wrong. This should be strongly typed, and both sender
-and receiver must know when either side screws up, so that they can recover properly and close any resources they have
-opened.
-
-On the receiving side we then have Output:
-
-[snippet,java]
---------------
-source=core/io/src/main/java/org/apache/zest/io/Output.java
-tag=output
--------------
-
-When receiveFrom is invoked by an Input, as a result of invoking transferTo on the Input, the Output should open
-whatever resources it needs to write to, and then expect data to come from a Sender. Both the Input and Output must
-have the same type T, so that they agree on what is being sent. We will see later how this can be handled if this is
-not the case.
-
-Next we have Sender:
-
-[snippet,java]
---------------
-source=core/io/src/main/java/org/apache/zest/io/Sender.java
-tag=sender
--------------
-
-The Output invokes sendTo and passes in a Receiver that the Sender will use to send individual items. The sender at
-this point can start transferring data of type T to the receiver, one at a time. The Receiver looks like this:
-
-[snippet,java]
---------------
-source=core/io/src/main/java/org/apache/zest/io/Receiver.java
-tag=receiver
--------------
-
-When the receiver gets the individual items from the sender it can either immediately write them to its underlying
-resource, or batch them up. Since the receiver will know when the transfer is done (sendTo returns) it can write the
-remaining batches properly and close any resource it holds.
-
-This simple pattern, with two interfaces on the sending side and two on the receiving side, gives us the potential to
-do scalable, performant and fault-tolerant transfers of data.
-
-== Standard Inputs and Outputs ==
-
-So now that the above API defines the contract of sending and receiving data, I can then create a couple of standard
-inputs and outputs. Let's say, reading lines of text from a file, and writing lines of text to a file. These
-implementations I can then put in static methods so they are easy to use. In the end, to make a copy of a text file
-looks like this:
-
-[snippet,java]
---------------
-source=manual/src/main/java/org/apache/zest/manual/recipes/io/Docs.java
-tag=filter
---------------
-
-One line of code that handles the reading, the writing, the cleaning up, buffering, and whatnot. Pretty nifty! The
-transferTo method will throw IOException, which I can catch if I want to present any errors to the user. But actually
-dealing with those errors, i.e. closing the files and potentially deleting the destination if the transfer failed, is
-already handled by the Input and Output. I will never have to deal with the details of reading text from a file ever
-again!
-
-== Intercepting the transfer ==
-
-While the above handles the basic input/output of a transfer, there are usually other things that I want to do as well.
-I may want to count how many items were transferred, do some filtering, or log every 1000 items or so to see what's
-going on. Since input and output are now separated this becomes simply a matter of inserting something in the middle
-that mediates the input and output. Since many of these mediations have a similar character I can put these into
-standard utility methods to make them easier to use.
-
-The first standard decorator is a filter. I will implement this by means of supplying a Specification:
-
-[source,java]
---------------
-public static <T,ReceiverThrowableType extends Throwable> Output<T, ReceiverThrowableType> filter( final Specification<T> specification, final Output<T, ReceiverThrowableType> output)
-{
-   ... create an Output that filters items based on the Specification<T> ...
-}
---------------
-
-Where Specification is:
-
-[source,java]
---------------
-interface Specification<T>
-{
-     boolean test(T item);
-}
---------------
-
-With this simple construct I can now perform transfers and easily filter out items I don't want on the receiving side.
-This example removes empty lines from a text file.
-
-[source,java]
---------------
-File source = ...
-File destination = ...
-Inputs.text( source ).transferTo( Transforms.filter(new Specification<String>()
-{
-   public boolean test(String string)
-   {
-      return string.length() != 0;
-   }
-}, Outputs.text(destination) );
---------------
-
-
-The second common operation is mapping from one type to the other. This deals with the case that one Input you have may
-not match the Output you want to send to, but there's a way to map from the input type to the output type. An example
-would be to map from String to JSONObject, for example. The operation itself looks like this:
-
-[source,java]
---------------
-public static <From,To,ReceiverThrowableType extends Throwable> Output<From, ReceiverThrowableType> map( Function<From,To> function, Output<To, ReceiverThrowableType> output)
---------------
-
-Where Function is defined as:
-
-[source,java]
---------------
-interface Function<From, To>
-{
-    To map(From from);
-}
---------------
-
-With this I can then connect an Input of Strings to an Output of JSONObject like so:
-
-[source,java]
---------------
-Input<String,IOException> input = ...;
-Output<JSONObject,RuntimeException> output = ...;
-input.transferTo(Transforms.map(new String2JSON(), output);
---------------
-
-Where String2JSON implements Function and it's map method converts the String into a JSONObject.
-
-At this point we can now deal with the last part of the initial example, the counting of items. This can be implemented
-as a generic Map that has the same input and output type, and just maintains a count internally that updates on every
-call to map(). The example can then be written as:
-
-[source,java]
---------------
-File source = ...
-File destination = ...
-Counter<String> counter = new Counter<String>();
-Inputs.text( source ).transferTo( Transforms.map(counter, Outputs.text(destination) ));
-System.out.println("Nr of lines:"+counter.getCount())
---------------
-
-== Usage in the Zest\u2122 SPI ==
-
-Now I can finally get back to my initial problem that led me to look into this: how to implement a good way to access
-EntityStates in a Zest\u2122 EntityStore, and perform restores of backups. The current version of accessing EntityStates look
-like this:
-
-[source,java]
---------------
-<ThrowableType extends Throwable> void visitEntityStates( EntityStateVisitor<ThrowableType> visitor, ModuleSPI module )
-     throws ThrowableType;
-
-interface EntityStateVisitor<ThrowableType extends Throwable>
-{
-  void visitEntityState( EntityState entityState )
-     throws ThrowableType;
-}
---------------
-
-This can now be replaced with:
-
-[source,java]
---------------
-Input<EntityState, EntityStoreException> entityStates(ModuleSPI module);
---------------
-
-Because of the pattern outlined above, users of this will get more information about what's happening in the traversal,
-such as if the EntityStore raised an EntityStoreException during the traversal, which they can then handle gracefully.
-It also becomes easy to add decorators such as maps and filters to users of this. Let's say you only are interested in
-EntityState's of a given type. Then add a filter for this, without changing the consumer.
-
-For importing backup data into an EntityStore, the interface used to look like this:
-
-[source,java]
---------------
-interface ImportSupport
-{
-    ImportResult importFrom( Reader in )
-            throws IOException;
-}
---------------
-
-This ties the EntityStore to only being able to read JSON lines from Reader's, the client will not know if the
-IOException raised is due to errors in the Reader or writing in the store, and the ImportResult, which contains a list
-of exceptions and count of stuff, is quite ugly to create and use. With the I/O API at hand this can now be replaced
-with:
-
-[source,java]
---------------
-interface ImportSupport
-{
-   Output<String,EntityStoreException> importJSON();
-}
---------------
-
-
-To use this, given the helpers outlined above, is as simple as:
-
-[source,java]
---------------
-File backup = ...
-ImportSupport entityStore = ...
-Inputs.text(backup).transferTo(entityStore.importJSON());
---------------
-
-If the client wants any "extras", such as counting how many objects were imported, this can be done by adding filters
-as previously shown. If you only want to, say, import entities modified before a particular date (let's say you know
-some junk was introduced after a given time), then add a specification filter that performs this check. And so on.
-
-== Conclusion ==
-
-It is quite common while developing software that you have to shuffle data or objects from one input to another output,
-possible with some transformations in the middle. Usually these things have to be done from scratch, which opens up for
-errors and badly applied patterns. By introducing a generic Input/Output API that encapsulates and separates these
-things properly it becomes easier to perform these tasks in a scalable, performant and error-free way, and while still
-allowing these tasks to be decorated with extra features when needed.
-
-This article has outlined one way to do this, and the API and helpers that I've described are available in the current
-Zest\u2122 Core 1.3-SNAPSHOT in Git (see Zest\u2122 homepage for access details). The idea is to start using it throughout Zest
-wherever we need to do I/O of the type described here.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/manual/src/docs/userguide/core.txt
----------------------------------------------------------------------
diff --git a/manual/src/docs/userguide/core.txt b/manual/src/docs/userguide/core.txt
index b6d77de..588de3c 100644
--- a/manual/src/docs/userguide/core.txt
+++ b/manual/src/docs/userguide/core.txt
@@ -75,15 +75,6 @@ such as Spring or Java EE applications.
 <<core-functional,Learn more>>
 //____
 
-//*<<core-io,Core I/O API>>*
-=== Core I/O API ===
-//____
-The Zest\u2122 Core I/O API tries to address the problem around shuffling data around from various I/O inputs and outputs,
-possibly with transformations and filtering along the way.
-
-<<core-io,Learn more>>
-//____
-
 //*<<core-spi,Core Extension SPI>>*
 === Core Extension SPI ===
 //____
@@ -123,10 +114,6 @@ include::../../../../core/functional/src/docs/functional.txt[]
 
 :leveloffset: 2
 
-include::../../../../core/io/src/docs/io.txt[]
-
-:leveloffset: 2
-
 include::../../../../core/spi/src/docs/spi.txt[]
 
 :leveloffset: 2

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/manual/src/docs/website/tutorials.txt
----------------------------------------------------------------------
diff --git a/manual/src/docs/website/tutorials.txt b/manual/src/docs/website/tutorials.txt
index 256d8e8..36f9a04 100644
--- a/manual/src/docs/website/tutorials.txt
+++ b/manual/src/docs/website/tutorials.txt
@@ -65,7 +65,6 @@ typical application.
 - <<howto-create-sideeffect>>
 - <<howto-create-entity>>
 - <<howto-configure-service>>
-- <<howto-use-io>>
 
 === Zest\u2122 Development ===
 
@@ -143,10 +142,6 @@ include::../tutorials/howto-invocation-annotation.txt[]
 
 :leveloffset: 2
 
-include::../tutorials/howto-use-io.txt[]
-
-:leveloffset: 2
-
 include::../tutorials/howto-build-system.txt[]
 
 :leveloffset: 2

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/manual/src/main/java/org/apache/zest/manual/recipes/io/Docs.java
----------------------------------------------------------------------
diff --git a/manual/src/main/java/org/apache/zest/manual/recipes/io/Docs.java b/manual/src/main/java/org/apache/zest/manual/recipes/io/Docs.java
deleted file mode 100644
index 23c0cd6..0000000
--- a/manual/src/main/java/org/apache/zest/manual/recipes/io/Docs.java
+++ /dev/null
@@ -1,39 +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.manual.recipes.io;
-
-import java.io.File;
-import java.io.IOException;
-import org.apache.zest.io.Inputs;
-import org.apache.zest.io.Outputs;
-
-public class Docs
-{
-
-    public void filter()
-        throws IOException
-    {
-// START SNIPPET: filter
-        File source = new File("source.txt");
-        File destination = new File("destination.txt");
-        Inputs.text( source ).transferTo( Outputs.text( destination ) );
-// END SNIPPET: filter
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/settings.gradle
----------------------------------------------------------------------
diff --git a/settings.gradle b/settings.gradle
index 0086623..97a817f 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -19,7 +19,6 @@
  */
 
 include 'core:functional',
-        'core:io',
         'core:api',
         'core:spi',
         'core:testsupport',


[5/7] zest-java git commit: Remove core/io

Posted by pa...@apache.org.
Remove core/io


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

Branch: refs/heads/develop
Commit: 37ce367a7d48496d191d867c3cc536b823b5ade1
Parents: 888e429
Author: Paul Merlin <pa...@apache.org>
Authored: Fri Dec 9 09:56:20 2016 +0100
Committer: Paul Merlin <pa...@apache.org>
Committed: Fri Dec 9 09:56:20 2016 +0100

----------------------------------------------------------------------
 .../apache/zest/gradle/RootProjectPlugin.groovy |   1 -
 .../org/apache/zest/gradle/ZestExtension.groovy |   1 -
 core/api/build.gradle                           |   2 +-
 core/api/src/docs/valuecomposite.txt            |  20 +-
 .../zest/api/value/DocumentationSupport.java    |  32 +-
 core/io/build.gradle                            |  27 -
 core/io/dev-status.xml                          |  36 --
 core/io/src/docs/io.txt                         | 217 --------
 core/io/src/docs/reference/ref-io.txt           |  18 -
 .../src/main/java/org/apache/zest/io/Files.java |  36 --
 .../src/main/java/org/apache/zest/io/Input.java |  39 --
 .../main/java/org/apache/zest/io/Inputs.java    | 496 -----------------
 .../main/java/org/apache/zest/io/Output.java    |  46 --
 .../main/java/org/apache/zest/io/Outputs.java   | 534 -------------------
 .../main/java/org/apache/zest/io/Receiver.java  |  42 --
 .../main/java/org/apache/zest/io/Sender.java    |  45 --
 .../java/org/apache/zest/io/Transforms.java     | 441 ---------------
 .../main/java/org/apache/zest/io/package.html   |  24 -
 .../org/apache/zest/io/InputOutputTest.java     | 386 --------------
 .../org/apache/zest/io/docsupport/IoDocs.java   |  54 --
 core/io/src/test/resources/iotest.txt           |   4 -
 manual/src/docs/tutorials/howto-use-io.txt      | 329 ------------
 manual/src/docs/userguide/core.txt              |  13 -
 manual/src/docs/website/tutorials.txt           |   5 -
 .../org/apache/zest/manual/recipes/io/Docs.java |  39 --
 settings.gradle                                 |   1 -
 26 files changed, 17 insertions(+), 2871 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/buildSrc/src/main/groovy/org/apache/zest/gradle/RootProjectPlugin.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/RootProjectPlugin.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/RootProjectPlugin.groovy
index 8c058d1..afc690a 100644
--- a/buildSrc/src/main/groovy/org/apache/zest/gradle/RootProjectPlugin.groovy
+++ b/buildSrc/src/main/groovy/org/apache/zest/gradle/RootProjectPlugin.groovy
@@ -163,7 +163,6 @@ class RootProjectPlugin implements Plugin<Project>
       options.group( [
         "Core API"      : [ "org.apache.zest.api",
                             "org.apache.zest.api.*",
-                            "org.apache.zest.io",
                             "org.apache.zest.functional" ],
         "Core Bootstrap": [ "org.apache.zest.bootstrap",
                             "org.apache.zest.bootstrap.*" ],

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestExtension.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestExtension.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestExtension.groovy
index de1f0d4..f57d8b4 100644
--- a/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestExtension.groovy
+++ b/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestExtension.groovy
@@ -50,7 +50,6 @@ class ZestExtension
     Dependency runtime = core( 'runtime' )
     Dependency bootstrap = core( 'bootstrap' )
     Dependency testsupport = core( 'testsupport' )
-    Dependency io = core( 'io' )
     Dependency functional = core( 'functional' )
   }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/core/api/build.gradle
----------------------------------------------------------------------
diff --git a/core/api/build.gradle b/core/api/build.gradle
index 8b717cd..ae8fc0c 100644
--- a/core/api/build.gradle
+++ b/core/api/build.gradle
@@ -21,7 +21,7 @@
 jar { manifest { name = "Apache Zest\u2122 Core API" } }
 
 dependencies {
-  compile zest.core.io
+  compile zest.core.functional
 
   testCompile zest.core.testsupport
   testCompile zest.library( 'constraints' )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/core/api/src/docs/valuecomposite.txt
----------------------------------------------------------------------
diff --git a/core/api/src/docs/valuecomposite.txt b/core/api/src/docs/valuecomposite.txt
index 8e8a88c..1517015 100644
--- a/core/api/src/docs/valuecomposite.txt
+++ b/core/api/src/docs/valuecomposite.txt
@@ -121,9 +121,7 @@ In this second example, we ;
     . use the +ValueSerializer#serialize()+ method to get a JSON representation of the Value,
     . and finally, use the +ValueDeserializer#eserialize()+ method to create a new Value instance from the JSON state.
 
-Many applications need to stream data. The ValueSerialization API support such use cases in two ways.
-
-The first one use classic streams.
+Many applications need to stream data. The ValueSerialization API support such use cases using classic streams:
 
 [snippet,java]
 ----
@@ -135,19 +133,3 @@ tag=stream
     . serialize data into the +OutputStream+,
     . get a handle on an +InputStream+,
     . deserialize data from the +InputStream+.
-
-The second one use the <<core-io>>:
-
-[snippet,java]
-----
-source=core/api/src/test/java/org/apache/zest/api/value/DocumentationSupport.java
-tag=io
-----
-
-    . get a handle on a source of values and a +Writer+,
-    . prepare the serialization +Function+,
-    . serialize a collection of values, one serialized value per line,
-    . get a handle on a serialized values +Reader+ and create a new empty +List+ of values,
-    . prepare the deserialization +Function+,
-    . deserialize a collection of values from read lines.
-

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/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
index 26a64e2..6d4a08a 100644
--- 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
@@ -24,14 +24,12 @@ 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.PrintWriter;
 import java.io.StringWriter;
-import java.io.Writer;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.function.Function;
+import java.util.stream.Stream;
 import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.property.Property;
 import org.apache.zest.api.structure.Application;
@@ -42,14 +40,11 @@ import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.Energy4Java;
 import org.apache.zest.bootstrap.ModuleAssembly;
 import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
-import org.apache.zest.io.Inputs;
-import org.apache.zest.io.Outputs;
-import org.apache.zest.io.Transforms;
 import org.apache.zest.test.AbstractZestTest;
 import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
-import org.junit.Before;
 import org.junit.Test;
 
+import static java.util.stream.Collectors.toList;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.junit.Assert.assertThat;
 
@@ -172,27 +167,30 @@ public class DocumentationSupport
         // END SNIPPET: io
 
         List<AcmeValue> dataSource = Arrays.asList( AcmeValue.values() );
-        StringWriter outputWriter = new StringWriter();
+        StringWriter stringOutput = new StringWriter();
+        PrintWriter output = new PrintWriter( stringOutput );
+
 
         // 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
+        // Eg. Entities converted to Values
+        Stream<AcmeValue> queryResult = dataSource.stream();
 
         // (2)
         Function<AcmeValue, String> serialize = valueSerializer.serialize();
 
         // (3)
-        Inputs.iterable( queryResult ).transferTo( Transforms.map( serialize, Outputs.text( writer ) ) );
+        // Eg. pipe data to another process or to a file
+        queryResult.map( serialize ).forEach( output::println );
         // END SNIPPET: io
 
-        String string = writer.toString();
-        StringReader inputReader = new StringReader( string );
+        output.flush();
+        String string = stringOutput.toString();
+        List<String> input = Arrays.asList( string.split( System.lineSeparator() ) );
 
         // START SNIPPET: io
         // (4)
-        Reader reader = inputReader;
-        List<AcmeValue> values = new ArrayList<AcmeValue>();
+        Stream<String> lines = input.stream();
 
         // (5)
         Function<String, AcmeValue> deserialize = valueDeserializer.deserialize( module, AcmeValue.class );
@@ -200,7 +198,7 @@ public class DocumentationSupport
         // 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 ) ) );
+        List<AcmeValue> values = lines.map( deserialize ).collect( toList() );
         // END SNIPPET: io
 
         assertThat( dataSource, equalTo( values ) );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/core/io/build.gradle
----------------------------------------------------------------------
diff --git a/core/io/build.gradle b/core/io/build.gradle
deleted file mode 100644
index 0e0c50a..0000000
--- a/core/io/build.gradle
+++ /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.
- *
- *
- */
-
-jar { manifest { name = "Apache Zest\u2122 I/O" } }
-
-dependencies {
-  compile zest.core.functional
-
-  testCompile zest.core.testsupport
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/core/io/dev-status.xml
----------------------------------------------------------------------
diff --git a/core/io/dev-status.xml b/core/io/dev-status.xml
deleted file mode 100644
index 412d5e3..0000000
--- a/core/io/dev-status.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-  ~  Licensed to the Apache Software Foundation (ASF) under one
-  ~  or more contributor license agreements.  See the NOTICE file
-  ~  distributed with this work for additional information
-  ~  regarding copyright ownership.  The ASF licenses this file
-  ~  to you under the Apache License, Version 2.0 (the
-  ~  "License"); you may not use this file except in compliance
-  ~  with the License.  You may obtain a copy of the License at
-  ~
-  ~       http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~  Unless required by applicable law or agreed to in writing, software
-  ~  distributed under the License is distributed on an "AS IS" BASIS,
-  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~  See the License for the specific language governing permissions and
-  ~  limitations under the License.
-  ~
-  ~
-  -->
-<module xmlns="http://zest.apache.org/schemas/2008/dev-status/1"
-        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xsi:schemaLocation="http://zest.apache.org/schemas/2008/dev-status/1
-        http://zest.apache.org/schemas/2008/dev-status/1/dev-status.xsd">
-  <status>
-    <codebase>beta</codebase>
-    <!--none,early,beta,stable,mature-->
-    <documentation>good</documentation>
-    <!-- none, brief, good, complete -->
-    <unittests>good</unittests>
-    <!-- none, some, good, complete -->
-  </status>
-  <licenses>
-    <license>ALv2</license>
-  </licenses>
-</module>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/core/io/src/docs/io.txt
----------------------------------------------------------------------
diff --git a/core/io/src/docs/io.txt b/core/io/src/docs/io.txt
deleted file mode 100644
index 3b1cb2e..0000000
--- a/core/io/src/docs/io.txt
+++ /dev/null
@@ -1,217 +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.
-//////////////////////
-
-[[core-io,I/O API]]
-= Core I/O API =
-
-[devstatus]
---------------
-source=core/io/dev-status.xml
---------------
-
-The Zest\u2122 Core I/O API is completely generic and not tied to the Zest\u2122 programming model as a whole. It can be used
-independently of Zest, together with the Zest\u2122 Core Functional API, which the Core I/O API depends on.
-
-The Zest\u2122 Core I/O API tries to address the problem around shuffling data around from various I/O inputs and outputs,
-possibly with transformations and filtering along the way. It was identified that there is a general mix-up of concerns
-in the stereotypical I/O handling codebases that people deal with all the time. The reasoning around this, can be found
-in the <<howto-use-io>>, and is recommended reading.
-
-include::../../build/docs/buildinfo/artifact.txt[]
-
-== The Problem ==
-Why does I/O operations in Java have to be so complicated, with nested try/catch/finally and loops? Don't you wish
-that the operations could be expressed in a more natural way, such as;
-
-[source,java]
--------------
-File source = ...
-File destination = ...
-source.copyTo( destination );
--------------
-
-It seems natural to do, yet it is not present for us. We need to involve FileInputStream/FileOutputStream, wrap them
-in Buffered versions of it, do our own looping, close the streams afterwards and what not. So, the java.io.File does
-not have this simple feature and in the Zest\u2122 Core API, we need to work around this limitation. We also want to
-make the abstraction a little bit more encompassing than "just" files. So how does that look like then?
-
-== First Examples ==
-The most common inputs and outputs are collected in the org.apache.zest.io.Inputs and org.apache.zest.io.Outputs classes as static
-factory methods, but you can create your (more about that later).
-
-So, we want to read a text file and write the content into another text file, right? This is how it is done;
-
-[snippet,java]
------------
-source=core/io/src/test/java/org/apache/zest/io/docsupport/IoDocs.java
-tag=io1
------------
-
-Pretty much self-explanatory, wouldn't you say? But what happened to the handling of exceptions and closing of
-resources? It is all handled inside the Zest\u2122 Core I/O API. There is nothing you can forget to do.
-
-Another simple example, where we want to count the number of lines in the text;
-
-[snippet,java]
------------
-source=core/io/src/test/java/org/apache/zest/io/docsupport/IoDocs.java
-tag=io2
------------
-
-The Counter is a <<core-functional>> which gets injected into the transfer.
-
-== The 3 Parts ==
-Ok, so we have seen that the end result can become pretty compelling. How does it work?
-
-I/O is defined as a process of moving data from an Input, via one or more Transforms to an Output. The Input could
-be a File or a String, the transformation could be a filter, conversion or a function and finally the Output
-destination could be a File, String or an OutputStream. It is important to note that there is a strong separation of
-concern between them. Let's look at the on at a time.
-
-== org.apache.zest.io.Input ==
-This interface simply has a transferTo() method, which takes an Output. The formal definition is;
-
-[snippet,java]
---------------
-source=core/io/src/main/java/org/apache/zest/io/Input.java
-tag=input
---------------
-
-What on earth is all this genericized Exceptions? Well, it abstracts away the explicit Exception that implementations
-may throw (or not). So instead of demanding that all I/O must throw the java.io.IOException, as is the case in the
-JDK classes, it is up to the implementation to declare what it may throw. That is found in the SenderThrowable generic
-of the interface.
-
-But hold on a second. Why is an Input throwing a "sender" exception? Well, think again. The Input is feeding "something"
-with data. It takes it from some source and "sends it" to the downstream chain, eventually reaching an Output, which
-likewise is the ultimate "receiver".
-
-So, then, the method transferTo() contains the declaration of the downstream receiver's possible Exception
-(ReceiverThrowable) which the transferTo() method may also throw as the data may not be accepted and such exception
-will bubble up to the transferTo() method (the client's view of the transfer).
-
-== org.apache.zest.io.Output ==
-The output interface is likewise fairly simple;
-
-[snippet,java]
---------------
-source=core/io/src/main/java/org/apache/zest/io/Output.java
-tag=output
---------------
-
-It can simply receive data from a org.apache.zest.io.Sender.
-
-Hey, hold on! Why is it not receiving from an Input? Because the Input is the client's entry point and of no use to
-the Output as such. Instead, the Output will tell the Sender (which is handed to from the Input or an transformation)
-to which Receiver the content should be sent to.
-
-Complicated? Perhaps not trivial to get your head around it at first, but the chain is;
-
-Input passes a Sender to the Output which tells the Sender which Receiver the data should be sent to.
-
-The reason for this is that we need to separate the concerns properly. Input is a starting point, but it emits something
-which is represented by the Sender. Likewise the destination is an Output, but it receives the data via its Receiver
-interface. For O/S resources, they are handled purely inside the Input and Output implementations, where are the
-Sender/Receiver are effectively dealing with the data itself.
-
-== org.apache.zest.io.Transforms ==
-The 3 component in the Zest\u2122 Core I/O API is the transformations that are possible. Interestingly enough, with the
-above separation of concerns, we don't need an InputOutput type that can both receive and send data. Instead, we
-simply need to prepare easy to use static factory methods, which are found in the org.apache.zest.io.Transforms class. Again,
-it is fairly straight forward to create your own Transforms if you need something not provided here.
-
-The current transformations available are;
-
-   * filter - takes a Specification and only forwards data items conforming to the Specification.
-   * map - takes a org.apache.zest.functional.Function to convert an item from one type to (potentially) another, and any
-     possible change along the way.
-   * filteredMap - is a combination of a filter and a map. If the Specification is satisfied, the map function is
-     applied, otherwise the item is passed through unaffected.
-   * lock - A wrapper which protects the Input or Output from simultaneous access. Not a transformation by itself,
-     but implemented in the same fashion.
-
-There are also a couple of handy map functions available, such as
-
-   * Log
-   * ProgressLog
-   * Counter
-   * ByteBuffer2String
-   * Object2String
-   * String2Bytes
-
-== Writing a Map Function? ==
-Let us take a closer look at the implementation of a map function, namely Counter mentioned above and also used in
-the section First Example above.
-
-The implementation is very straight forward.
-
-[snippet,java]
---------------
-source=core/io/src/main/java/org/apache/zest/io/Transforms.java
-tag=counter
---------------
-
-On each call to the map() method, increment the counter field. The client can then retrieve that value after the
-transfer is complete, or in a separate thread to show progress.
-
-Speaking of "progress", so how is the ProgressLog implemented? Glad you asked;
-
-[snippet,java]
---------------
-source=core/io/src/main/java/org/apache/zest/io/Transforms.java
-tag=progress
---------------
-
-It combines the Counter and the Log implementations, so that the count is forwarded to the Log at a given interval, such
-as every 1000 items. This may not be what you think a ProgressLog should look like, but it serves as a good example on
-how you can combine the general principles found in the Zest\u2122 Core API package.
-
-== How to write a filter specification? ==
-The filter transform takes a regular java.util.function.Predicate as an argument, where the implementation needs to
-return *true* or *false* for whether the item passed in is within
-the limits. Let's say that you have a IntegerRangeSpecification, which could then be implemented as
-
-[snippet,java]
---------------
-source=core/functional/src/test/java/org/apache/zest/functional/IntegerRangeSpecificationTest.java
-tag=specification
---------------
-
-== Ready-to-use components ==
-Input and Output implementations at first glance look quite scary. Taking a closer look and it can be followed. But to
-simplify for users, the org.apache.zest.io.Inputs and org.apache.zest.io.Outputs contains static factory methods for many useful
-sources and destinations.
-
-== org.apache.zest.io.Inputs ==
-The current set of ready-to-use Input implementations are;
-
-[snippet,java]
---------------
-source=core/io/src/main/java/org/apache/zest/io/Inputs.java
-tag=method
---------------
-
-== org.apache.zest.io.Outputs ==
-The current set of ready-to-use Input implementations are;
-
-[snippet,java]
---------------
-source=core/io/src/main/java/org/apache/zest/io/Outputs.java
-tag=method
---------------
-

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/core/io/src/docs/reference/ref-io.txt
----------------------------------------------------------------------
diff --git a/core/io/src/docs/reference/ref-io.txt b/core/io/src/docs/reference/ref-io.txt
deleted file mode 100644
index fc7aac6..0000000
--- a/core/io/src/docs/reference/ref-io.txt
+++ /dev/null
@@ -1,18 +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.
-///////////////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37ce367a/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 a70b2f9..0000000
--- a/core/io/src/main/java/org/apache/zest/io/Files.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.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/37ce367a/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 0841926..0000000
--- a/core/io/src/main/java/org/apache/zest/io/Input.java
+++ /dev/null
@@ -1,39 +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;
-
-/**
- * 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/37ce367a/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 3a6041a..0000000
--- a/core/io/src/main/java/org/apache/zest/io/Inputs.java
+++ /dev/null
@@ -1,496 +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.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/37ce367a/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 11ba3b5..0000000
--- a/core/io/src/main/java/org/apache/zest/io/Output.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.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/37ce367a/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 f21204c..0000000
--- a/core/io/src/main/java/org/apache/zest/io/Outputs.java
+++ /dev/null
@@ -1,534 +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.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/37ce367a/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 2cf94f9..0000000
--- a/core/io/src/main/java/org/apache/zest/io/Receiver.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.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/37ce367a/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 1ebe4d1..0000000
--- a/core/io/src/main/java/org/apache/zest/io/Sender.java
+++ /dev/null
@@ -1,45 +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;
-
-/**
- * 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


[7/7] zest-java git commit: Remove core/functional

Posted by pa...@apache.org.
Remove core/functional

Moved Visitor to api.util


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

Branch: refs/heads/develop
Commit: 0b4cca0680e29990bb45e4795f56535dee6924e2
Parents: 37ce367
Author: Paul Merlin <pa...@apache.org>
Authored: Fri Dec 9 10:12:29 2016 +0100
Committer: Paul Merlin <pa...@apache.org>
Committed: Fri Dec 9 10:12:29 2016 +0100

----------------------------------------------------------------------
 .../apache/zest/gradle/RootProjectPlugin.groovy |  3 +-
 .../org/apache/zest/gradle/ZestExtension.groovy |  1 -
 core/api/build.gradle                           |  2 -
 .../api/structure/ApplicationDescriptor.java    |  2 +-
 .../zest/api/util/HierarchicalVisitor.java      | 57 ++++++++++++++
 .../api/util/HierarchicalVisitorAdapter.java    | 48 ++++++++++++
 .../org/apache/zest/api/util/Visitable.java     | 29 +++++++
 .../zest/api/util/VisitableHierarchy.java       | 29 +++++++
 .../java/org/apache/zest/api/util/Visitor.java  | 39 ++++++++++
 core/functional/build.gradle                    | 25 ------
 core/functional/dev-status.xml                  | 36 ---------
 core/functional/src/docs/functional.txt         | 82 --------------------
 .../src/docs/reference/ref-functional.txt       | 18 -----
 .../zest/functional/HierarchicalVisitor.java    | 57 --------------
 .../functional/HierarchicalVisitorAdapter.java  | 48 ------------
 .../org/apache/zest/functional/Visitable.java   | 29 -------
 .../zest/functional/VisitableHierarchy.java     | 29 -------
 .../org/apache/zest/functional/Visitor.java     | 39 ----------
 .../org/apache/zest/functional/package.html     | 24 ------
 .../IntegerRangeSpecificationTest.java          | 64 ---------------
 .../functional/docsupport/FunctionalDocs.java   | 52 -------------
 .../zest/runtime/activation/ActivatorModel.java |  4 +-
 .../runtime/activation/ActivatorsModel.java     |  6 +-
 .../runtime/association/AssociationModel.java   |  4 +-
 .../runtime/association/AssociationsModel.java  |  4 +-
 .../association/ManyAssociationModel.java       |  4 +-
 .../association/ManyAssociationsModel.java      |  4 +-
 .../association/NamedAssociationModel.java      |  4 +-
 .../association/NamedAssociationsModel.java     |  4 +-
 .../bootstrap/ApplicationModelFactoryImpl.java  |  2 +-
 .../bootstrap/CompositeAssemblyImpl.java        |  2 +-
 .../composite/AbstractConstraintModel.java      |  4 +-
 .../composite/AbstractModifierModel.java        |  4 +-
 .../runtime/composite/CompositeMethodModel.java | 15 +---
 .../composite/CompositeMethodsModel.java        |  4 +-
 .../zest/runtime/composite/CompositeModel.java  |  4 +-
 .../zest/runtime/composite/ConcernsModel.java   |  4 +-
 .../runtime/composite/ConstraintsModel.java     |  4 +-
 .../runtime/composite/ConstructorModel.java     |  4 +-
 .../runtime/composite/ConstructorsModel.java    |  6 +-
 .../zest/runtime/composite/MixinModel.java      |  4 +-
 .../zest/runtime/composite/MixinsModel.java     | 11 ++-
 .../runtime/composite/SideEffectsModel.java     |  4 +-
 .../zest/runtime/composite/StateModel.java      |  4 +-
 .../zest/runtime/composite/TransientsModel.java |  4 +-
 .../composite/ValueConstraintsModel.java        |  4 +-
 .../zest/runtime/entity/EntitiesModel.java      |  4 +-
 .../zest/runtime/entity/EntityStateModel.java   |  4 +-
 .../zest/runtime/injection/DependencyModel.java |  4 +-
 .../runtime/injection/InjectedFieldModel.java   |  4 +-
 .../runtime/injection/InjectedFieldsModel.java  |  4 +-
 .../runtime/injection/InjectedMethodModel.java  |  4 +-
 .../runtime/injection/InjectedMethodsModel.java |  4 +-
 .../injection/InjectedParametersModel.java      |  4 +-
 .../apache/zest/runtime/object/ObjectModel.java |  4 +-
 .../zest/runtime/object/ObjectsModel.java       |  4 +-
 .../zest/runtime/property/PropertiesModel.java  |  4 +-
 .../zest/runtime/property/PropertyModel.java    |  4 +-
 .../runtime/service/ImportedServiceModel.java   |  4 +-
 .../runtime/service/ImportedServicesModel.java  |  4 +-
 .../zest/runtime/service/ServiceModel.java      |  2 +-
 .../zest/runtime/service/ServicesModel.java     |  4 +-
 .../runtime/structure/ApplicationModel.java     |  2 +-
 .../zest/runtime/structure/LayerModel.java      |  4 +-
 .../zest/runtime/structure/ModuleModel.java     |  4 +-
 .../zest/runtime/structure/UsedLayersModel.java |  4 +-
 .../zest/runtime/types/ValueTypeFactory.java    |  2 +-
 .../zest/runtime/value/ValueStateModel.java     |  4 +-
 .../apache/zest/runtime/value/ValuesModel.java  |  4 +-
 .../bootstrap/ApplicationAssemblerTest.java     |  2 +-
 .../apache/zest/regression/qi78/IssueTest.java  |  2 +-
 .../support/skeletons/AbstractSQLStartup.java   |  2 +-
 .../apache/zest/library/appbrowser/Browser.java |  2 +-
 .../circuitbreaker/src/docs/circuitbreaker.txt  |  2 +-
 .../library/jmx/ApplicationManagerService.java  |  2 +-
 .../library/rdf/model/ApplicationVisitor.java   |  2 +-
 .../zest/library/rdf/model/Model2XML.java       |  2 +-
 .../internal/service/ServiceLocator.java        |  2 +-
 .../zest/library/sql/common/Databases.java      |  2 +-
 manual/src/docs/userguide/core.txt              | 15 ----
 settings.gradle                                 |  3 +-
 .../descriptor/ActivatorDetailDescriptor.java   |  4 +-
 .../descriptor/ApplicationDetailDescriptor.java |  4 +-
 .../ApplicationDetailDescriptorBuilder.java     |  2 +-
 .../descriptor/EntityDetailDescriptor.java      |  4 +-
 .../ImportedServiceDetailDescriptor.java        |  4 +-
 .../model/descriptor/LayerDetailDescriptor.java |  4 +-
 .../descriptor/ModuleDetailDescriptor.java      |  4 +-
 .../descriptor/ObjectDetailDescriptor.java      |  4 +-
 .../descriptor/ServiceDetailDescriptor.java     |  4 +-
 .../descriptor/TransientDetailDescriptor.java   |  4 +-
 .../model/descriptor/ValueDetailDescriptor.java |  4 +-
 .../zest/tools/model/VisitableDetailTest.java   |  4 +-
 93 files changed, 337 insertions(+), 664 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/buildSrc/src/main/groovy/org/apache/zest/gradle/RootProjectPlugin.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/RootProjectPlugin.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/RootProjectPlugin.groovy
index afc690a..e669c99 100644
--- a/buildSrc/src/main/groovy/org/apache/zest/gradle/RootProjectPlugin.groovy
+++ b/buildSrc/src/main/groovy/org/apache/zest/gradle/RootProjectPlugin.groovy
@@ -162,8 +162,7 @@ class RootProjectPlugin implements Plugin<Project>
       } )
       options.group( [
         "Core API"      : [ "org.apache.zest.api",
-                            "org.apache.zest.api.*",
-                            "org.apache.zest.functional" ],
+                            "org.apache.zest.api.*" ],
         "Core Bootstrap": [ "org.apache.zest.bootstrap",
                             "org.apache.zest.bootstrap.*" ],
         "Core SPI"      : [ "org.apache.zest.spi",

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestExtension.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestExtension.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestExtension.groovy
index f57d8b4..4d6184b 100644
--- a/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestExtension.groovy
+++ b/buildSrc/src/main/groovy/org/apache/zest/gradle/ZestExtension.groovy
@@ -50,7 +50,6 @@ class ZestExtension
     Dependency runtime = core( 'runtime' )
     Dependency bootstrap = core( 'bootstrap' )
     Dependency testsupport = core( 'testsupport' )
-    Dependency functional = core( 'functional' )
   }
 
   private Dependency core( String name )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/core/api/build.gradle
----------------------------------------------------------------------
diff --git a/core/api/build.gradle b/core/api/build.gradle
index ae8fc0c..c854d18 100644
--- a/core/api/build.gradle
+++ b/core/api/build.gradle
@@ -21,8 +21,6 @@
 jar { manifest { name = "Apache Zest\u2122 Core API" } }
 
 dependencies {
-  compile zest.core.functional
-
   testCompile zest.core.testsupport
   testCompile zest.library( 'constraints' )
   testCompile zest.extension( 'valueserialization-orgjson' )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 3b7b4a4..111c092 100644
--- 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
@@ -20,7 +20,7 @@
 package org.apache.zest.api.structure;
 
 import org.apache.zest.api.ZestAPI;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 /**
  * Application Descriptor.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/core/api/src/main/java/org/apache/zest/api/util/HierarchicalVisitor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/HierarchicalVisitor.java b/core/api/src/main/java/org/apache/zest/api/util/HierarchicalVisitor.java
new file mode 100644
index 0000000..8a1c53e
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/util/HierarchicalVisitor.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.apache.zest.api.util;
+
+/**
+ * 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/0b4cca06/core/api/src/main/java/org/apache/zest/api/util/HierarchicalVisitorAdapter.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/HierarchicalVisitorAdapter.java b/core/api/src/main/java/org/apache/zest/api/util/HierarchicalVisitorAdapter.java
new file mode 100644
index 0000000..1a2357b
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/util/HierarchicalVisitorAdapter.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.apache.zest.api.util;
+
+/**
+ * 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/0b4cca06/core/api/src/main/java/org/apache/zest/api/util/Visitable.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/Visitable.java b/core/api/src/main/java/org/apache/zest/api/util/Visitable.java
new file mode 100644
index 0000000..49cceec
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/util/Visitable.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.apache.zest.api.util;
+
+/**
+ * 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/0b4cca06/core/api/src/main/java/org/apache/zest/api/util/VisitableHierarchy.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/VisitableHierarchy.java b/core/api/src/main/java/org/apache/zest/api/util/VisitableHierarchy.java
new file mode 100644
index 0000000..642c32e
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/util/VisitableHierarchy.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.apache.zest.api.util;
+
+/**
+ * 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/0b4cca06/core/api/src/main/java/org/apache/zest/api/util/Visitor.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/util/Visitor.java b/core/api/src/main/java/org/apache/zest/api/util/Visitor.java
new file mode 100644
index 0000000..dff2309
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/util/Visitor.java
@@ -0,0 +1,39 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.zest.api.util;
+
+/**
+ * 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/0b4cca06/core/functional/build.gradle
----------------------------------------------------------------------
diff --git a/core/functional/build.gradle b/core/functional/build.gradle
deleted file mode 100644
index 91d7170..0000000
--- a/core/functional/build.gradle
+++ /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.
- *
- *
- */
-
-jar { manifest { name = "Apache Zest\u2122 Functional"}}
-
-dependencies {
-
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/core/functional/dev-status.xml
----------------------------------------------------------------------
diff --git a/core/functional/dev-status.xml b/core/functional/dev-status.xml
deleted file mode 100644
index 412d5e3..0000000
--- a/core/functional/dev-status.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
-  ~  Licensed to the Apache Software Foundation (ASF) under one
-  ~  or more contributor license agreements.  See the NOTICE file
-  ~  distributed with this work for additional information
-  ~  regarding copyright ownership.  The ASF licenses this file
-  ~  to you under the Apache License, Version 2.0 (the
-  ~  "License"); you may not use this file except in compliance
-  ~  with the License.  You may obtain a copy of the License at
-  ~
-  ~       http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~  Unless required by applicable law or agreed to in writing, software
-  ~  distributed under the License is distributed on an "AS IS" BASIS,
-  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~  See the License for the specific language governing permissions and
-  ~  limitations under the License.
-  ~
-  ~
-  -->
-<module xmlns="http://zest.apache.org/schemas/2008/dev-status/1"
-        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-        xsi:schemaLocation="http://zest.apache.org/schemas/2008/dev-status/1
-        http://zest.apache.org/schemas/2008/dev-status/1/dev-status.xsd">
-  <status>
-    <codebase>beta</codebase>
-    <!--none,early,beta,stable,mature-->
-    <documentation>good</documentation>
-    <!-- none, brief, good, complete -->
-    <unittests>good</unittests>
-    <!-- none, some, good, complete -->
-  </status>
-  <licenses>
-    <license>ALv2</license>
-  </licenses>
-</module>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/core/functional/src/docs/functional.txt
----------------------------------------------------------------------
diff --git a/core/functional/src/docs/functional.txt b/core/functional/src/docs/functional.txt
deleted file mode 100644
index eb6dbb6..0000000
--- a/core/functional/src/docs/functional.txt
+++ /dev/null
@@ -1,82 +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.
-//////////////////////
-
-[[core-functional,Function]]
-= Core Functional API =
-
-[devstatus]
---------------
-source=core/functional/dev-status.xml
---------------
-
-The Zest\u2122 Core Functional API is a generic package to work with Iterables in a "functional programming language" style.
-
-This package is completely independent of everything else in Zest\u2122 and may be used on its own in any kind of environment
-such as Spring or Java EE applications.
-
-include::../../build/docs/buildinfo/artifact.txt[]
-
-== First Example ==
-Let's say that you have an Iterable of Integers and you want to sum them all up. Most people would create a loop and
-sum it all up in something like this;
-
-[snippet,java]
------------
-source=core/functional/src/test/java/org/apache/zest/functional/docsupport/FunctionalDocs.java
-tag=func1
------------
-
-With the Zest\u2122 Core Functional API, you go about it in a different way. The code ends up looking like this;
-
-[snippet,java]
------------
-source=core/functional/src/test/java/org/apache/zest/functional/docsupport/FunctionalDocs.java
-tag=func2
------------
-
-And this is just the tip of the iceberg.
-
-== The Big Picture ==
-
-The Zest\u2122 Core Functional API are divided a handful of powerful concepts, especially when used together;
-
-   * *Iterables* - many methods to deal with Iterable data, so that the loops in your programs can largely be removed.
-
-   * *Functions* - f(x) and f(x,y) are well-know from mathematics and used in functional programming languages. Zest\u2122 is
-     not capable of introducing lambda calculus due to limitations in Java itself, but we can simulate a lot to allow
-     people to create more readable code.
-
-   * *Specification* - A simple concept to define the bounds of data. This is used for filtering, query and many other
-     higher level abstractions.
-
-   * *Visitor* pattern - A way to be handed the items in a collection, without having the loops. This could be for
-     end result handling, distribution of intermediary values, and many other things.
-
-
-== Specification ==
-TODO
-
-== Function ==
-TODO
-
-== Visitor Pattern ==
-TODO
-
-== Iterables ==
-TODO
-

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/core/functional/src/docs/reference/ref-functional.txt
----------------------------------------------------------------------
diff --git a/core/functional/src/docs/reference/ref-functional.txt b/core/functional/src/docs/reference/ref-functional.txt
deleted file mode 100644
index fc7aac6..0000000
--- a/core/functional/src/docs/reference/ref-functional.txt
+++ /dev/null
@@ -1,18 +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.
-///////////////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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 167f3fb..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/HierarchicalVisitor.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.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/0b4cca06/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 121d9aa..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/HierarchicalVisitorAdapter.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.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/0b4cca06/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 50f8b21..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/Visitable.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.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/0b4cca06/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 bb1b0ab..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/VisitableHierarchy.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.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/0b4cca06/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 bfe8097..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/Visitor.java
+++ /dev/null
@@ -1,39 +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/0b4cca06/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 c8535c4..0000000
--- a/core/functional/src/main/java/org/apache/zest/functional/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>Functional API.</h2>
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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 0a19371..0000000
--- a/core/functional/src/test/java/org/apache/zest/functional/IntegerRangeSpecificationTest.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.functional;
-
-import java.util.function.Predicate;
-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()
-    {
-        Predicate<Integer> spec = new IntegerRangeSpecification( 10, 12 );
-        assertTrue( spec.test( 10 ) );
-        assertTrue( spec.test( 11 ) );
-        assertTrue( spec.test( 12 ) );
-        assertFalse( spec.test( 9 ) );
-        assertFalse( spec.test( 13 ) );
-    }
-
-    // START SNIPPET: specification
-    public static class IntegerRangeSpecification
-        implements Predicate<Integer>
-    {
-
-        private int lower;
-        private int higher;
-
-        public IntegerRangeSpecification( int lower, int higher )
-        {
-            this.lower = lower;
-            this.higher = higher;
-        }
-
-        @Override
-        public boolean test( Integer item )
-        {
-            return item >= lower && item <= higher;
-        }
-    }
-    // END SNIPPET: specification
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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 b99cf9b..0000000
--- a/core/functional/src/test/java/org/apache/zest/functional/docsupport/FunctionalDocs.java
+++ /dev/null
@@ -1,52 +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;
-import java.util.stream.StreamSupport;
-
-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<Long> data = new ArrayList<>();
-            Long total = StreamSupport.stream( data.spliterator(), true ).reduce( 0L, ( sum, n ) -> sum + n );
-            System.out.println( "The sum is " + total );
-
-// END SNIPPET: func2
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index c1f52bf..fa7a3c5 100644
--- 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
@@ -22,8 +22,8 @@ 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.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.composite.ConstructorsModel;
 import org.apache.zest.runtime.injection.InjectedFieldsModel;
 import org.apache.zest.runtime.injection.InjectedMethodsModel;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 3622cac..6aa25c7 100644
--- 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
@@ -23,13 +23,11 @@ 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.api.structure.ModuleDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.composite.UsesInstance;
 import org.apache.zest.runtime.injection.InjectionContext;
-import org.apache.zest.runtime.structure.ModuleInstance;
 
 /**
  * Activators Model.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index d8ca0c9..ee3092c 100644
--- 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
@@ -36,9 +36,9 @@ 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.api.util.Visitable;
+import org.apache.zest.api.util.Visitor;
 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;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index f4714a3..8f5aa46 100644
--- 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
@@ -28,8 +28,8 @@ 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;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 /**
  * Model for Associations.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index e2974a4..1db4d4f 100644
--- 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
@@ -40,9 +40,9 @@ 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.api.util.Visitable;
+import org.apache.zest.api.util.Visitor;
 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;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 7f02ce4..cde6d79 100644
--- 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
@@ -27,8 +27,8 @@ import java.util.stream.Stream;
 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.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.unitofwork.ModuleUnitOfWork;
 import org.apache.zest.runtime.value.ValueStateInstance;
 import org.apache.zest.spi.entity.EntityState;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 71b6bbd..29e1165 100644
--- 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
@@ -40,9 +40,9 @@ 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.api.util.Visitable;
+import org.apache.zest.api.util.Visitor;
 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;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index ec1888b..5cf8ab3 100644
--- 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
@@ -27,8 +27,8 @@ import java.util.stream.Stream;
 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.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.unitofwork.ModuleUnitOfWork;
 import org.apache.zest.runtime.value.ValueStateInstance;
 import org.apache.zest.spi.entity.EntityState;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index ff7bf84..ed22f92 100644
--- 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
@@ -29,12 +29,12 @@ 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.api.util.HierarchicalVisitor;
 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;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index b0731c3..82632a9 100644
--- 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
@@ -67,8 +67,8 @@ 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.api.util.HierarchicalVisitorAdapter;
 import org.apache.zest.bootstrap.StateDeclarations;
-import org.apache.zest.functional.HierarchicalVisitorAdapter;
 import org.apache.zest.runtime.association.AssociationModel;
 import org.apache.zest.runtime.association.AssociationsModel;
 import org.apache.zest.runtime.association.ManyAssociationModel;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 9667e75..f8f8aa1 100644
--- 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
@@ -22,8 +22,8 @@ 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;
+import org.apache.zest.api.util.Visitable;
+import org.apache.zest.api.util.Visitor;
 
 /**
  * JAVADOC

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 0d7f8b5..6a8186e 100644
--- 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
@@ -27,8 +27,8 @@ import java.lang.reflect.Proxy;
 import java.util.stream.Stream;
 import org.apache.zest.api.common.ConstructionException;
 import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.injection.Dependencies;
 import org.apache.zest.runtime.injection.DependencyModel;
 import org.apache.zest.runtime.injection.InjectedFieldsModel;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index be8a07c..9da3388 100644
--- 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
@@ -28,17 +28,17 @@ import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import org.apache.zest.api.common.ConstructionException;
 import org.apache.zest.api.composite.MethodDescriptor;
 import org.apache.zest.api.structure.ModuleDescriptor;
+import org.apache.zest.api.util.HierarchicalVisitor;
 import org.apache.zest.api.util.NullArgumentException;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.injection.Dependencies;
 import org.apache.zest.runtime.injection.DependencyModel;
-import org.apache.zest.spi.module.ModuleSpi;
 
 /**
  * JAVADOC
@@ -100,14 +100,7 @@ public final class CompositeMethodModel
     @SuppressWarnings( "unchecked" )
     public Stream<DependencyModel> dependencies()
     {
-        // For some unknown reason, the following lines can not be put into a single expression.
-        // This is possibly due to a compiler or JVM bug. The problem manifests itself in
-        // failure inside the AssociationToValueTest and possibly others.
-        // java.lang.invoke.LambdaConversionException: Invalid receiver type interface org.apache.zest.functional.VisitableHierarchy; not a subtype of implementation type interface org.apache.zest.runtime.injection.Dependencies
-        // Since it is a runtime bug, we should not change this in Java 8, but if the problem is gone in Java 9,
-        // we can collapse these into a single expression.
-        Stream<? extends Dependencies> deps = Stream.of( this.concerns, sideEffects );
-        return deps.filter( e -> e != null ).flatMap( Dependencies::dependencies );
+        return Stream.of( this.concerns, sideEffects ).filter( Objects::nonNull ).flatMap( Dependencies::dependencies );
     }
 
     // Context

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 4d7b795..6314d22 100644
--- 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
@@ -26,8 +26,8 @@ import java.util.LinkedHashMap;
 import java.util.stream.Stream;
 import org.apache.zest.api.composite.MissingMethodException;
 import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.injection.Dependencies;
 import org.apache.zest.runtime.injection.DependencyModel;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index eb9ddb7..e6acf6a 100644
--- 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
@@ -34,8 +34,8 @@ 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.api.structure.ModuleDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.injection.Dependencies;
 import org.apache.zest.runtime.injection.DependencyModel;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index a1c6b2b..42b7b90 100644
--- 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
@@ -27,8 +27,8 @@ import java.util.List;
 import java.util.stream.Stream;
 import org.apache.zest.api.concern.ConcernsDescriptor;
 import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.injection.Dependencies;
 import org.apache.zest.runtime.injection.DependencyModel;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 0c0d400..2233dff 100644
--- 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
@@ -24,8 +24,8 @@ 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;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 /**
  * JAVADOC

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 0362682..ae1dffa 100644
--- 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
@@ -27,8 +27,8 @@ import java.util.stream.Stream;
 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.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.injection.DependencyModel;
 import org.apache.zest.runtime.injection.InjectedParametersModel;
 import org.apache.zest.runtime.injection.InjectionContext;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index db6c2e1..2ae338c 100644
--- 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
@@ -37,10 +37,10 @@ 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.Classes;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.HierarchicalVisitorAdapter;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.bootstrap.BindingException;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.HierarchicalVisitorAdapter;
-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;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 621237d..82ff417 100644
--- 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
@@ -32,8 +32,8 @@ 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.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.injection.Dependencies;
 import org.apache.zest.runtime.injection.DependencyModel;
 import org.apache.zest.runtime.injection.InjectedFieldsModel;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index d3564c1..3878528 100644
--- 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
@@ -32,10 +32,10 @@ import java.util.Map;
 import java.util.Set;
 import java.util.stream.Stream;
 import org.apache.zest.api.util.Classes;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.HierarchicalVisitorAdapter;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.bootstrap.BindingException;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.HierarchicalVisitorAdapter;
-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.InjectedFieldModel;
@@ -210,12 +210,16 @@ public class MixinsModel
         @Override
         public Collection<MixinModel> uses( MixinModel source )
         {
+            // System.out.println("BEGIN> MixinsModel.Uses.uses( "+source+" )");
             Iterable<Class<?>> thisMixinTypes = source.thisMixinTypes();
             List<MixinModel> usedMixinClasses = new ArrayList<MixinModel>();
+            // System.out.println("\tSource Mixin Types and Methods: ");
             for( Class thisMixinType : thisMixinTypes )
             {
+                // System.out.println("\t\t"+thisMixinType);
                 for( Method method : thisMixinType.getMethods() )
                 {
+                    // System.out.println("\t\t\t"+method);
                     if( !Modifier.isStatic( method.getModifiers() ) )
                     {
                         MixinModel used = methodImplementation.get( method );
@@ -223,6 +227,7 @@ public class MixinsModel
                     }
                 }
             }
+            // System.out.println( "END>   MixinsModel.Uses.uses( " + source + " )" );
             return usedMixinClasses;
         }
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 0e0db3f..4ed29eb 100644
--- 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
@@ -28,8 +28,8 @@ import java.util.List;
 import java.util.stream.Stream;
 import org.apache.zest.api.sideeffect.SideEffectsDescriptor;
 import org.apache.zest.api.structure.ModuleDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.injection.Dependencies;
 import org.apache.zest.runtime.injection.DependencyModel;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index dfef14e..2f17d61 100644
--- 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
@@ -23,8 +23,8 @@ import java.lang.reflect.AccessibleObject;
 import java.util.stream.Stream;
 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.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.property.PropertiesModel;
 import org.apache.zest.runtime.property.PropertyModel;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 265d26c..e785ca2 100644
--- 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
@@ -23,8 +23,8 @@ package org.apache.zest.runtime.composite;
 import java.util.List;
 import java.util.stream.Stream;
 import org.apache.zest.api.composite.TransientDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 /**
  * JAVADOC

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 4971a09..b2febfe 100644
--- 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
@@ -21,8 +21,8 @@
 package org.apache.zest.runtime.composite;
 
 import java.util.List;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 /**
  * JAVADOC

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index f9dcce2..d1feb77 100644
--- 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
@@ -23,8 +23,8 @@ package org.apache.zest.runtime.entity;
 import java.util.List;
 import java.util.stream.Stream;
 import org.apache.zest.api.entity.EntityDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 /**
  * Model of entities in a particular Module.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index c602d76..fec1be6 100644
--- 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
@@ -24,8 +24,8 @@ import java.util.stream.Stream;
 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.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.association.AssociationModel;
 import org.apache.zest.runtime.association.AssociationsModel;
 import org.apache.zest.runtime.association.ManyAssociationModel;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index bc8f914..8110920 100644
--- 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
@@ -31,10 +31,10 @@ import java.util.stream.Stream;
 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.api.util.Visitable;
+import org.apache.zest.api.util.Visitor;
 import org.apache.zest.bootstrap.BindingException;
 import org.apache.zest.bootstrap.InvalidInjectionException;
-import org.apache.zest.functional.Visitable;
-import org.apache.zest.functional.Visitor;
 import org.apache.zest.runtime.injection.provider.CachingInjectionProviderDecorator;
 import org.apache.zest.runtime.injection.provider.InjectionProviderException;
 import org.apache.zest.runtime.injection.provider.ServiceInjectionProviderFactory;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 0c13db5..73044ab 100644
--- 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
@@ -30,10 +30,10 @@ import java.util.stream.Stream;
 import org.apache.zest.api.composite.DependencyDescriptor;
 import org.apache.zest.api.composite.InjectedFieldDescriptor;
 import org.apache.zest.api.util.Classes;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.bootstrap.BindingException;
 import org.apache.zest.bootstrap.InjectionException;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
 import org.apache.zest.runtime.composite.TransientInstance;
 import org.apache.zest.runtime.model.Resolution;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 125e73a..5fec5e5 100644
--- 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
@@ -33,8 +33,8 @@ import java.util.stream.Stream;
 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.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 import static org.apache.zest.api.util.Annotations.typeHasAnnotation;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 0f15a95..39a220b 100644
--- 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
@@ -24,9 +24,9 @@ import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.stream.Stream;
 import org.apache.zest.api.composite.InjectedMethodDescriptor;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.bootstrap.InjectionException;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
 
 /**
  * JAVADOC

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index b303ea6..9e5538b 100644
--- 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
@@ -32,8 +32,8 @@ import java.util.stream.Stream;
 import org.apache.zest.api.injection.InjectionScope;
 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.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 import static org.apache.zest.api.util.Annotations.typeHasAnnotation;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index c057a92..0f1ea4b 100644
--- 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
@@ -24,8 +24,8 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Stream;
 import org.apache.zest.api.composite.InjectedParametersDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 /**
  * JAVADOC

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 554a026..f64faa9 100644
--- 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
@@ -28,8 +28,8 @@ 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.api.structure.ModuleDescriptor;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 import org.apache.zest.runtime.composite.ConstructorsModel;
 import org.apache.zest.runtime.injection.InjectedFieldsModel;
 import org.apache.zest.runtime.injection.InjectedMethodsModel;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index 2322f45..b7a2bc8 100644
--- 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
@@ -22,8 +22,8 @@ package org.apache.zest.runtime.object;
 
 import java.util.List;
 import java.util.stream.Stream;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 /**
  * JAVADOC

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index cfc77be..30a0fcf 100644
--- 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
@@ -25,8 +25,8 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.stream.Stream;
 import org.apache.zest.api.common.QualifiedName;
-import org.apache.zest.functional.HierarchicalVisitor;
-import org.apache.zest.functional.VisitableHierarchy;
+import org.apache.zest.api.util.HierarchicalVisitor;
+import org.apache.zest.api.util.VisitableHierarchy;
 
 /**
  * Base class for properties model

http://git-wip-us.apache.org/repos/asf/zest-java/blob/0b4cca06/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
index d854bb3..b943cbe 100644
--- 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
@@ -46,9 +46,9 @@ import org.apache.zest.api.type.ValueType;
 import org.apache.zest.api.util.Classes;
 import org.apache.zest.api.value.MissingValueSerializationException;
 import org.apache.zest.api.value.ValueDeserializer;
+import org.apache.zest.api.util.Visitable;
+import org.apache.zest.api.util.Visitor;
 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;