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/11/28 18:27:25 UTC

[1/5] zest-java git commit: runtime: refine TypeLookup

Repository: zest-java
Updated Branches:
  refs/heads/develop d313c1329 -> dc30f4b41


runtime: refine TypeLookup


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

Branch: refs/heads/develop
Commit: ebe9f8c7f2e4d4d540c8dbe57cb78d86b1cc92a8
Parents: d313c13
Author: Paul Merlin <pa...@apache.org>
Authored: Mon Nov 28 17:20:51 2016 +0100
Committer: Paul Merlin <pa...@apache.org>
Committed: Mon Nov 28 17:20:51 2016 +0100

----------------------------------------------------------------------
 .../zest/runtime/structure/TypeLookupImpl.java    | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/ebe9f8c7/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
index f9cc137..f3e8a4e 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java
@@ -50,11 +50,6 @@ import static org.apache.zest.api.util.Classes.interfacesOf;
 class TypeLookupImpl
     implements TypeLookup
 {
-
-    // Constructor parameters
-    private final ModuleDescriptor moduleModel;
-
-    // Eager instance objects
     private final LazyValue<List<ObjectDescriptor>> allObjects;
     private final LazyValue<List<TransientDescriptor>> allTransients;
     private final LazyValue<List<ValueDescriptor>> allValues;
@@ -63,11 +58,13 @@ class TypeLookupImpl
     private final ConcurrentHashMap<Class<?>, ObjectDescriptor> objectModels;
     private final ConcurrentHashMap<Class<?>, TransientDescriptor> transientModels;
     private final ConcurrentHashMap<Class<?>, ValueDescriptor> valueModels;
-    private final ConcurrentHashMap<Class<?>, List<EntityDescriptor>> allEntityModels;
+    private final ConcurrentHashMap<Class<?>, List<EntityDescriptor>> entityModels;
     private final ConcurrentHashMap<Class<?>, EntityDescriptor> unambiguousEntityModels;
     private final ConcurrentHashMap<Type, ModelDescriptor> serviceModels;
     private final ConcurrentHashMap<Type, List<? extends ModelDescriptor>> servicesReferences;
 
+    private final ModuleDescriptor moduleModel;
+
     /**
      * Create a new TypeLookup bound to the given moduleModel.
      *
@@ -75,10 +72,9 @@ class TypeLookupImpl
      */
     TypeLookupImpl( ModuleModel module )
     {
-        // Constructor parameters
-        this.moduleModel = module;
+        moduleModel = module;
 
-        // Eager instance objects
+        // Instance caches
         allObjects = new LazyValue<>();
         allTransients = new LazyValue<>();
         allValues = new LazyValue<>();
@@ -87,7 +83,7 @@ class TypeLookupImpl
         objectModels = new ConcurrentHashMap<>();
         transientModels = new ConcurrentHashMap<>();
         valueModels = new ConcurrentHashMap<>();
-        allEntityModels = new ConcurrentHashMap<>();
+        entityModels = new ConcurrentHashMap<>();
         unambiguousEntityModels = new ConcurrentHashMap<>();
         serviceModels = new ConcurrentHashMap<>();
         servicesReferences = new ConcurrentHashMap<>();
@@ -241,7 +237,7 @@ class TypeLookupImpl
     @Override
     public List<EntityDescriptor> lookupEntityModels( final Class type )
     {
-        return allEntityModels.computeIfAbsent( type, key ->
+        return entityModels.computeIfAbsent( type, key ->
             concat(
                 allEntities().filter( ref -> new ExactTypeMatching<>( key ).test( ref ) ),
                 allEntities().filter( ref -> new AssignableFromTypeMatching<>( key ).test( ref ) )


[2/5] zest-java git commit: remove core/io usage from tests & helpers in libraries & extensions

Posted by pa...@apache.org.
remove core/io usage from tests & helpers in libraries & extensions


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

Branch: refs/heads/develop
Commit: a660c7106925bbe5f7ae824fa5e051c972327f1c
Parents: ebe9f8c
Author: Paul Merlin <pa...@apache.org>
Authored: Mon Nov 28 17:28:24 2016 +0100
Committer: Paul Merlin <pa...@apache.org>
Committed: Mon Nov 28 17:45:06 2016 +0100

----------------------------------------------------------------------
 .../AbstractCollectionSerializationTest.java    |  18 ---
 .../jclouds/JCloudsMapEntityStoreMixin.java     |  47 ++----
 .../apache/zest/library/groovy/GroovyMixin.java |  24 +--
 .../sql/liquibase/LiquibaseServiceTest.java     |  24 ++-
 libraries/sql/src/docs/sql.txt                  |  15 +-
 .../zest/library/sql/common/Databases.java      | 156 ++++---------------
 ...taSourceConfigurationManagerServiceTest.java | 145 ++++-------------
 7 files changed, 96 insertions(+), 333 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/a660c710/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractCollectionSerializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractCollectionSerializationTest.java b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractCollectionSerializationTest.java
index d843d6f..15ad941 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractCollectionSerializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractCollectionSerializationTest.java
@@ -44,11 +44,6 @@ import org.apache.zest.functional.Iterables;
 import org.apache.zest.test.AbstractZestTest;
 import org.junit.Test;
 
-import static org.apache.zest.io.Inputs.iterable;
-import static org.apache.zest.io.Inputs.text;
-import static org.apache.zest.io.Outputs.collection;
-import static org.apache.zest.io.Outputs.text;
-import static org.apache.zest.io.Transforms.map;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 
@@ -72,19 +67,6 @@ public class AbstractCollectionSerializationTest
     protected ValueSerialization valueSerialization;
 
     @Test
-    public void testIOString()
-        throws Exception
-    {
-        StringBuilder sb = new StringBuilder();
-        iterable( byteCollection() ).transferTo( map( valueSerialization.serialize(), text( sb ) ) );
-        String output = sb.toString();
-
-        List<Byte> list = new ArrayList<>();
-        text( output ).transferTo( map( valueSerialization.deserialize( module, Byte.class ), collection( list ) ) );
-        assertEquals( byteCollection(), list );
-    }
-
-    @Test
     public void givenPrimitiveArrayWithIntsWhenSerializingAndDeserializingExpectEquals()
         throws Exception
     {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a660c710/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 37c0d0e..f8c2ac1 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
@@ -24,7 +24,6 @@ import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Maps;
 import com.google.common.io.ByteSource;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -32,33 +31,33 @@ import java.io.Reader;
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.Writer;
+import java.nio.charset.StandardCharsets;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Scanner;
 import java.util.Set;
-import org.jclouds.ContextBuilder;
-import org.jclouds.apis.ApiMetadata;
-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;
 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.Inputs;
 import org.apache.zest.io.Output;
-import org.apache.zest.io.Outputs;
 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 org.jclouds.ContextBuilder;
+import org.jclouds.apis.ApiMetadata;
+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;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -179,31 +178,15 @@ public class JCloudsMapEntityStoreMixin
         {
             throw new EntityNotFoundException( entityReference );
         }
-        InputStream input = null;
-        try
+        try( InputStream input = payload.openStream() )
         {
-            input = payload.openStream();
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            Inputs.byteBuffer( input, 4096 ).transferTo( Outputs.byteBuffer( baos ) );
-            return new StringReader( baos.toString( "UTF-8" ) );
+            String state = new Scanner( input, StandardCharsets.UTF_8.name() ).useDelimiter( "\\Z" ).next();
+            return new StringReader( state );
         }
         catch( IOException ex )
         {
             throw new EntityStoreException( "Unable to read entity state for: " + entityReference, ex );
         }
-        finally
-        {
-            if( input != null )
-            {
-                try
-                {
-                    input.close();
-                }
-                catch( IOException ignored )
-                {
-                }
-            }
-        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a660c710/libraries/lang-groovy/src/main/java/org/apache/zest/library/groovy/GroovyMixin.java
----------------------------------------------------------------------
diff --git a/libraries/lang-groovy/src/main/java/org/apache/zest/library/groovy/GroovyMixin.java b/libraries/lang-groovy/src/main/java/org/apache/zest/library/groovy/GroovyMixin.java
index 2e55911..64449c5 100644
--- a/libraries/lang-groovy/src/main/java/org/apache/zest/library/groovy/GroovyMixin.java
+++ b/libraries/lang-groovy/src/main/java/org/apache/zest/library/groovy/GroovyMixin.java
@@ -32,12 +32,11 @@ import java.lang.reflect.Method;
 import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Scanner;
 import org.apache.zest.api.common.AppliesTo;
 import org.apache.zest.api.common.AppliesToFilter;
 import org.apache.zest.api.composite.Composite;
 import org.apache.zest.api.injection.scope.This;
-import org.apache.zest.io.Inputs;
-import org.apache.zest.io.Outputs;
 
 /**
  * Generic mixin that implements interfaces by delegating to Groovy functions
@@ -75,8 +74,7 @@ public class GroovyMixin
 
     public GroovyMixin()
     {
-
-        groovyObjects = new HashMap<Class, GroovyObject>();
+        groovyObjects = new HashMap<>();
     }
 
     @Override
@@ -104,22 +102,12 @@ public class GroovyMixin
             GroovyObject groovyObject = groovyObjects.get( declaringClass );
             if( groovyObject == null )
             {
-                InputStream is = null;
                 final Class groovyClass;
-                try
+                try( InputStream inputStream = groovySource.openStream() )
                 {
-                    is = groovySource.openStream();
-                    StringBuilder sourceBuilder = new StringBuilder();
-                    Inputs.text( groovySource ).transferTo( Outputs.text( sourceBuilder ) );
+                    String sourceText = new Scanner( inputStream ).useDelimiter( "\\Z" ).next();
                     GroovyClassLoader groovyClassLoader = new GroovyClassLoader( declaringClass.getClassLoader() );
-                    groovyClass = groovyClassLoader.parseClass( sourceBuilder.toString() );
-                }
-                finally
-                {
-                    if( is != null )
-                    {
-                        is.close();
-                    }
+                    groovyClass = groovyClassLoader.parseClass( sourceText );
                 }
                 groovyObject = (GroovyObject) groovyClass.newInstance();
                 if( hasProperty( groovyObject, "This" ) )
@@ -210,7 +198,5 @@ public class GroovyMixin
             this.script = script;
             this.url = url;
         }
-
     }
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a660c710/libraries/sql-liquibase/src/test/java/org/apache/zest/library/sql/liquibase/LiquibaseServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/sql-liquibase/src/test/java/org/apache/zest/library/sql/liquibase/LiquibaseServiceTest.java b/libraries/sql-liquibase/src/test/java/org/apache/zest/library/sql/liquibase/LiquibaseServiceTest.java
index 2a85472..83ef261 100644
--- a/libraries/sql-liquibase/src/test/java/org/apache/zest/library/sql/liquibase/LiquibaseServiceTest.java
+++ b/libraries/sql-liquibase/src/test/java/org/apache/zest/library/sql/liquibase/LiquibaseServiceTest.java
@@ -26,8 +26,6 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.function.Function;
 import javax.sql.DataSource;
-import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
-import org.junit.Test;
 import org.apache.zest.api.activation.ActivationEvent;
 import org.apache.zest.api.activation.ActivationEventListener;
 import org.apache.zest.api.activation.ActivationException;
@@ -40,18 +38,15 @@ import org.apache.zest.api.value.ValueComposite;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
 import org.apache.zest.bootstrap.SingletonAssembler;
-import org.apache.zest.io.Inputs;
-import org.apache.zest.io.Outputs;
 import org.apache.zest.library.sql.assembly.DataSourceAssembler;
 import org.apache.zest.library.sql.common.Databases;
 import org.apache.zest.library.sql.dbcp.DBCPDataSourceServiceAssembler;
 import org.apache.zest.test.EntityTestAssembler;
+import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
-import static org.apache.zest.io.Outputs.collection;
-import static org.apache.zest.io.Transforms.map;
 
 /**
  * Test DataSource and Liquibase services
@@ -92,8 +87,6 @@ public class LiquibaseServiceTest
                 // END SNIPPET: assembly
                 module.forMixin( LiquibaseConfiguration.class ).declareDefaults().enabled().set( true );
                 module.forMixin( LiquibaseConfiguration.class ).declareDefaults().changeLog().set( "changelog.xml" );
-
-                new DefaultUnitOfWorkAssembler().assemble( module );
             }
 
             @Override
@@ -159,14 +152,17 @@ public class LiquibaseServiceTest
             }
         };
 
-        // START SNIPPET: io
-        // Select rows and load them in a List
         List<SomeValue> rows = new ArrayList<SomeValue>();
-        database.query( "select * from test" ).transferTo( map( toValue, collection( rows ) ) );
+        database.query( "select * from test", new Databases.ResultSetVisitor() {
+            @Override
+            public boolean visit( final ResultSet resultSet ) throws SQLException
+            {
+                rows.add( toValue.apply( resultSet ) );
+                return true;
+            }
+        } );
 
-        // Transfer all rows to System.out
-        Inputs.iterable( rows ).transferTo( Outputs.systemOut() );
-        // END SNIPPET: io
+        rows.forEach( System.out::println );
     }
 
     interface SomeValue

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a660c710/libraries/sql/src/docs/sql.txt
----------------------------------------------------------------------
diff --git a/libraries/sql/src/docs/sql.txt b/libraries/sql/src/docs/sql.txt
index 76f1e24..9f9413a 100644
--- a/libraries/sql/src/docs/sql.txt
+++ b/libraries/sql/src/docs/sql.txt
@@ -29,7 +29,7 @@ source=libraries/sql/dev-status.xml
 The SQL Library provides facilities for working with SQL databases.
 
 The center piece is the DataSource support that comes with
-<<library-circuitbreaker>> and <<library-jmx>> support. Facilities for doing SQL I/O with the <<core-io>> are provided.
+<<library-circuitbreaker>> and <<library-jmx>> support.
 
 TIP: See the <<sample-sql-support>> that demonstrate combined use of <<library-sql>>, <<extension-es-sql>> and
 <<extension-indexing-sql>>.
@@ -164,19 +164,6 @@ tag=cb-datasource
 
 
 
-
-== I/O ==
-
-Here is a simple example:
-
-[snippet,java]
-----
-source=libraries/sql-liquibase/src/test/java/org/apache/zest/library/sql/liquibase/LiquibaseServiceTest.java
-tag=io
-----
-
-
-
 == JMX ==
 
 Thanks to the <<library-jmx>> the Configuration of DataSources is exposed

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a660c710/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 9b03a38..4d66954 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
@@ -25,17 +25,12 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import javax.sql.DataSource;
 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;
 
 /**
  * Utility methods for performing SQL calls wrapping a given DataSource.
  */
 public class Databases
 {
-
     DataSource source;
 
     /**
@@ -50,15 +45,18 @@ public class Databases
      * Perform SQL update statement.
      */
     public int update( String sql )
-            throws SQLException
+        throws SQLException
     {
         Connection connection = null;
         PreparedStatement stmt = null;
-        try {
+        try
+        {
             connection = source.getConnection();
             stmt = connection.prepareStatement( sql );
             return stmt.executeUpdate();
-        } finally {
+        }
+        finally
+        {
             SQLUtil.closeQuietly( stmt );
             SQLUtil.closeQuietly( connection );
         }
@@ -71,16 +69,19 @@ public class Databases
      * update the PreparedStatement with actual values.
      */
     public int update( String sql, StatementVisitor visitor )
-            throws SQLException
+        throws SQLException
     {
         Connection connection = null;
         PreparedStatement stmt = null;
-        try {
+        try
+        {
             connection = source.getConnection();
             stmt = connection.prepareStatement( sql );
             visitor.visit( stmt );
             return stmt.executeUpdate();
-        } finally {
+        }
+        finally
+        {
             SQLUtil.closeQuietly( stmt );
             SQLUtil.closeQuietly( connection );
         }
@@ -90,7 +91,7 @@ public class Databases
      * Perform SQL query and let visitor handle results.
      */
     public void query( String sql, ResultSetVisitor visitor )
-            throws SQLException
+        throws SQLException
     {
         query( sql, null, visitor );
     }
@@ -101,137 +102,47 @@ public class Databases
      * If the SQL string contains ? placeholders, use the StatementVisitor to
      * update the PreparedStatement with actual values.
      */
-    public void query( String sql, StatementVisitor statement, ResultSetVisitor resultsetVisitor )
-            throws SQLException
+    public void query( String sql, StatementVisitor statementVisitor, ResultSetVisitor resultSetVisitor )
+        throws SQLException
     {
         Connection connection = null;
-        PreparedStatement stmt = null;
+        PreparedStatement statement = null;
         ResultSet resultSet = null;
-        try {
+        try
+        {
             connection = source.getConnection();
-            stmt = connection.prepareStatement( sql );
-            if ( statement != null ) {
-                statement.visit( stmt );
+            statement = connection.prepareStatement( sql );
+            if( statementVisitor != null )
+            {
+                statementVisitor.visit( statement );
             }
-            resultSet = stmt.executeQuery();
-            while ( resultSet.next() ) {
-                if ( !resultsetVisitor.visit( resultSet ) ) {
+            resultSet = statement.executeQuery();
+            while( resultSet.next() )
+            {
+                if( !resultSetVisitor.visit( resultSet ) )
+                {
                     return;
                 }
             }
             resultSet.close();
-        } finally {
+        }
+        finally
+        {
             SQLUtil.closeQuietly( resultSet );
-            SQLUtil.closeQuietly( stmt );
+            SQLUtil.closeQuietly( statement );
             SQLUtil.closeQuietly( connection );
         }
     }
 
     /**
-     * Perform SQL query and provide results as an Input.
-     *
-     * This makes it possible to combine SQL data with the I/O API.
-     */
-    public Input<ResultSet, SQLException> query( final String sql )
-    {
-        return new Input<ResultSet, SQLException>()
-        {
-
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super ResultSet, ReceiverThrowableType> output )
-                    throws SQLException, ReceiverThrowableType
-            {
-                output.receiveFrom( new Sender<ResultSet, SQLException>()
-                {
-
-                    @Override
-                    public <ReceiverThrowableType extends Throwable> void sendTo( final Receiver<? super ResultSet, ReceiverThrowableType> receiver )
-                            throws ReceiverThrowableType, SQLException
-                    {
-                        query( sql, new ResultSetVisitor()
-                        {
-
-                            @Override
-                            public boolean visit( ResultSet visited )
-                                    throws SQLException
-                            {
-                                try {
-                                    receiver.receive( visited );
-                                } catch ( Throwable receiverThrowableType ) {
-                                    throw new SQLException( receiverThrowableType );
-                                }
-
-                                return true;
-                            }
-
-                        } );
-                    }
-
-                } );
-            }
-
-        };
-    }
-
-    /**
-     * Perform SQL query and provide results as an Input.
-     *
-     * This makes it possible to combine SQL data with the I/O API. If the SQL
-     * string contains ? placeholders, use the StatementVisitor to update the
-     * PreparedStatement with actual values.
-     */
-    public Input<ResultSet, SQLException> query( final String sql, final StatementVisitor visitor )
-    {
-        return new Input<ResultSet, SQLException>()
-        {
-
-            @Override
-            public <ReceiverThrowableType extends Throwable> void transferTo( Output<? super ResultSet, ReceiverThrowableType> output )
-                    throws SQLException, ReceiverThrowableType
-            {
-                output.receiveFrom( new Sender<ResultSet, SQLException>()
-                {
-
-                    @Override
-                    public <ReceiverThrowableType extends Throwable> void sendTo( final Receiver<? super ResultSet, ReceiverThrowableType> receiver )
-                            throws ReceiverThrowableType, SQLException
-                    {
-                        query( sql, visitor, new ResultSetVisitor()
-                        {
-
-                            @Override
-                            public boolean visit( ResultSet visited )
-                                    throws SQLException
-                            {
-                                try {
-                                    receiver.receive( visited );
-                                } catch ( Throwable receiverThrowableType ) {
-                                    throw new SQLException( receiverThrowableType );
-                                }
-
-                                return true;
-                            }
-
-                        } );
-                    }
-
-                } );
-            }
-
-        };
-    }
-
-    /**
      * Visitor for PreparedStatements.
      *
      * These are created when the SQL statements contain ? placeholders.
      */
     public interface StatementVisitor
     {
-
         void visit( PreparedStatement preparedStatement )
-                throws SQLException;
-
+            throws SQLException;
     }
 
     /**
@@ -241,8 +152,7 @@ public class Databases
      * by this API.
      */
     public interface ResultSetVisitor
-            extends Visitor<ResultSet, SQLException>
+        extends Visitor<ResultSet, SQLException>
     {
     }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/a660c710/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java
----------------------------------------------------------------------
diff --git a/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java b/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java
index 79dc1ad..81a2f5a 100644
--- a/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java
+++ b/libraries/sql/src/test/java/org/apache/zest/library/sql/jmx/DataSourceConfigurationManagerServiceTest.java
@@ -19,33 +19,21 @@
  */
 package org.apache.zest.library.sql.jmx;
 
-import java.beans.PropertyVetoException;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import javax.sql.DataSource;
-import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
-import org.junit.Assert;
-import org.junit.Test;
 import org.apache.zest.api.activation.ActivationException;
 import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.service.ServiceReference;
-import org.apache.zest.api.service.qualifier.IdentifiedBy;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
 import org.apache.zest.bootstrap.SingletonAssembler;
-import org.apache.zest.io.Outputs;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.library.circuitbreaker.CircuitBreaker;
+import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.apache.zest.library.jmx.JMXAssembler;
 import org.apache.zest.library.sql.assembly.DataSourceAssembler;
 import org.apache.zest.library.sql.assembly.DataSourceJMXAssembler;
-import org.apache.zest.library.sql.common.Databases;
 import org.apache.zest.library.sql.datasource.DataSources;
 import org.apache.zest.library.sql.dbcp.DBCPDataSourceServiceAssembler;
 import org.apache.zest.library.sql.liquibase.LiquibaseConfiguration;
 import org.apache.zest.library.sql.liquibase.LiquibaseService;
 import org.apache.zest.test.EntityTestAssembler;
+import org.junit.Test;
 
 /**
  * Test of export of DataSources to JMX, and some other stuff
@@ -61,10 +49,14 @@ public class DataSourceConfigurationManagerServiceTest
         instance.testDataSources();
 
         // Hang so it becomes possible to connect through VisualVM and check the JMX beans
-        synchronized( instance ) {
-            try {
+        synchronized( instance )
+        {
+            try
+            {
                 instance.wait();
-            } catch ( InterruptedException e ) {
+            }
+            catch( InterruptedException e )
+            {
                 e.printStackTrace();
             }
         }
@@ -74,11 +66,11 @@ public class DataSourceConfigurationManagerServiceTest
     public void testDataSources()
         throws ActivationException, AssemblyException
     {
-        new SingletonAssembler()
+        SingletonAssembler assembler = new SingletonAssembler()
         {
             @Override
             public void assemble( ModuleAssembly module )
-                    throws AssemblyException
+                throws AssemblyException
             {
                 new JMXAssembler().assemble( module );
 
@@ -88,24 +80,27 @@ public class DataSourceConfigurationManagerServiceTest
                 new DefaultUnitOfWorkAssembler().assemble( module );
 
                 // Set up DataSource service that will manage the connection pools
-                new DBCPDataSourceServiceAssembler().identifiedBy( "datasource-service" ).visibleIn( Visibility.layer ).assemble( module );
+                new DBCPDataSourceServiceAssembler().identifiedBy( "datasource-service" )
+                                                    .visibleIn( Visibility.layer )
+                                                    .assemble( module );
 
                 {
                     ModuleAssembly testModule = module.layer().module( "TestDS" );
 
                     // Create a specific DataSource that uses the "datasource" service to do the main work
-                    new DataSourceAssembler().
-                            withDataSourceServiceIdentity( "datasource-service" ).
-                            identifiedBy( "testds" ).
-                            visibleIn( Visibility.module ).
-                            withCircuitBreaker( DataSources.newDataSourceCircuitBreaker() ).
-                            assemble( testModule );
+                    new DataSourceAssembler().withDataSourceServiceIdentity( "datasource-service" )
+                                             .identifiedBy( "testds" )
+                                             .visibleIn( Visibility.module )
+                                             .withCircuitBreaker( DataSources.newDataSourceCircuitBreaker() )
+                                             .assemble( testModule );
 
                     // Set up Liquibase service that will create the tables
                     testModule.services( LiquibaseService.class ).identifiedBy( "liquibase1" ).instantiateOnStartup();
                     testModule.entities( LiquibaseConfiguration.class );
-                    testModule.forMixin( LiquibaseConfiguration.class ).declareDefaults().enabled().set( true );
-                    testModule.forMixin( LiquibaseConfiguration.class ).declareDefaults().changeLog().set( "changelog.xml" );
+                    testModule.forMixin( LiquibaseConfiguration.class ).declareDefaults()
+                              .enabled().set( true );
+                    testModule.forMixin( LiquibaseConfiguration.class ).declareDefaults()
+                              .changeLog().set( "changelog.xml" );
                 }
 
                 {
@@ -113,101 +108,25 @@ public class DataSourceConfigurationManagerServiceTest
 
                     // Create another specific DataSource that uses the "datasource" service to do the main work
                     // Use DataSourceAssembler to assemble the DataSource.
-                    new DataSourceAssembler().
-                            withDataSourceServiceIdentity( "datasource-service" ).
-                            identifiedBy( "testds2" ).
-                            visibleIn( Visibility.module ).
-                            withCircuitBreaker( DataSources.newDataSourceCircuitBreaker() ).
-                            assemble( testModule2 );
+                    new DataSourceAssembler().withDataSourceServiceIdentity( "datasource-service" )
+                                             .identifiedBy( "testds2" )
+                                             .visibleIn( Visibility.module )
+                                             .withCircuitBreaker( DataSources.newDataSourceCircuitBreaker() )
+                                             .assemble( testModule2 );
 
                     // Set up Liquibase service that will create the tables
                     testModule2.services( LiquibaseService.class ).identifiedBy( "liquibase2" ).instantiateOnStartup();
                     testModule2.entities( LiquibaseConfiguration.class );
-                    testModule2.forMixin( LiquibaseConfiguration.class ).declareDefaults().enabled().set( true );
-                    testModule2.forMixin( LiquibaseConfiguration.class ).declareDefaults().changeLog().set( "changelog.xml" );
+                    testModule2.forMixin( LiquibaseConfiguration.class ).declareDefaults()
+                               .enabled().set( true );
+                    testModule2.forMixin( LiquibaseConfiguration.class ).declareDefaults()
+                               .changeLog().set( "changelog.xml" );
                 }
 
                 // START SNIPPET: jmx
                 new DataSourceJMXAssembler().visibleIn( Visibility.module ).assemble( module );
                 // END SNIPPET: jmx
-
             }
-
         };
-
-//        assembler.application().findModule( "Layer 1","Test" ).objectBuilderFactory().newObjectBuilder( DataSourceConfigurationManagerServiceTest.class ).injectTo( this );
     }
-
-    public void init( @Service @IdentifiedBy( "testds" ) DataSource dataSource, @Service @IdentifiedBy( "testds2" ) ServiceReference<DataSource> dataSource2 )
-            throws SQLException, PropertyVetoException
-    {
-        Databases databases = new Databases( dataSource );
-
-        // Insert some data and print it out
-        databases.update( "insert into test values ('id1','foo')" );
-        databases.query( "select * from test" ).transferTo( Outputs.withReceiver( new Receiver<ResultSet, SQLException>()
-        {
-            @Override
-            public void receive( ResultSet item )
-                    throws SQLException
-            {
-                System.out.println( item.getString( "id" ) );
-            }
-
-        } ) );
-
-        Databases databases2 = new Databases( dataSource2.get() );
-
-        // Insert some data and print it out
-        databases2.update( "insert into test values ('id2','bar')" );
-        databases2.query( "select * from test" ).transferTo( Outputs.withReceiver( new Receiver<ResultSet, SQLException>()
-        {
-            @Override
-            public void receive( ResultSet item )
-                    throws SQLException
-            {
-                System.out.println( item.getString( "id" ) );
-            }
-
-        } ) );
-
-        // Trip the CB
-        dataSource2.metaInfo( CircuitBreaker.class ).trip();
-
-        // This should now fail
-        try {
-            databases2.query( "select * from test" ).transferTo( Outputs.withReceiver( new Receiver<ResultSet, SQLException>()
-            {
-                @Override
-                public void receive( ResultSet item )
-                        throws SQLException
-                {
-                    System.out.println( item.getString( "id" ) );
-                }
-
-            } ) );
-
-            Assert.fail();
-
-        } catch ( Throwable e ) {
-            // Correct
-        }
-
-        // Turn the CB back on
-        dataSource2.metaInfo( CircuitBreaker.class ).turnOn();
-
-        // This should now work
-        databases2.query( "select * from test" ).transferTo( Outputs.withReceiver( new Receiver<ResultSet, SQLException>()
-        {
-            @Override
-            public void receive( ResultSet item )
-                    throws SQLException
-            {
-                System.out.println( item.getString( "id" ) );
-            }
-
-        } ) );
-
-    }
-
 }


[4/5] zest-java git commit: free-port-finder: remove range in which one port was seen busy

Posted by pa...@apache.org.
free-port-finder: remove range in which one port was seen busy


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

Branch: refs/heads/develop
Commit: 1a9f6857f21a4de0c2952d6e9ecc4c14818ed905
Parents: 398a5e8
Author: Paul Merlin <pa...@apache.org>
Authored: Mon Nov 28 18:50:30 2016 +0100
Committer: Paul Merlin <pa...@apache.org>
Committed: Mon Nov 28 18:50:30 2016 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/zest/test/util/FreePortFinder.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/1a9f6857/core/testsupport/src/main/java/org/apache/zest/test/util/FreePortFinder.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/util/FreePortFinder.java b/core/testsupport/src/main/java/org/apache/zest/test/util/FreePortFinder.java
index f69c5f8..3791ea1 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/util/FreePortFinder.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/util/FreePortFinder.java
@@ -55,7 +55,7 @@ public class FreePortFinder
     private static final List<Range> LEAST_USED_RANGES = Arrays.asList(
         new Range( 29170, 29998 ),
         new Range( 38866, 39680 ),
-        new Range( 41798, 42507 ),
+        // new Range( 41798, 42507 ), // 42187 seen busy
         new Range( 43442, 44122 ),
         new Range( 46337, 46997 ),
         new Range( 35358, 36000 ),


[3/5] zest-java git commit: remove some more uses of core/functional

Posted by pa...@apache.org.
remove some more uses of core/functional


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

Branch: refs/heads/develop
Commit: 398a5e8c9e542a18d428d4af8b9b2ac71b69d75a
Parents: a660c71
Author: Paul Merlin <pa...@apache.org>
Authored: Mon Nov 28 18:49:24 2016 +0100
Committer: Paul Merlin <pa...@apache.org>
Committed: Mon Nov 28 18:49:24 2016 +0100

----------------------------------------------------------------------
 .../zest/bootstrap/builder/LayerDeclaration.java       |  7 +++++--
 .../zest/bootstrap/builder/ModuleDeclaration.java      | 13 ++++++-------
 .../zest/bootstrap/builder/ApplicationBuilderTest.java |  8 ++++----
 .../zest/library/rest/server/api/ObjectSelection.java  |  5 ++---
 4 files changed, 17 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/398a5e8c/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java
index 65936cc..96e712f 100644
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java
+++ b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/LayerDeclaration.java
@@ -23,11 +23,13 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.StreamSupport;
 import org.apache.zest.bootstrap.ApplicationAssembly;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.LayerAssembly;
 import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.functional.Iterables;
+
+import static java.util.stream.Collectors.toCollection;
 
 /**
  * Provides declared {@link org.apache.zest.api.structure.Layer} information that the {@link ApplicationBuilder} can use.
@@ -62,7 +64,8 @@ public class LayerDeclaration
      */
     public LayerDeclaration using( Iterable<String> layerNames )
     {
-        Iterables.addAll( using, layerNames );
+        StreamSupport.stream( layerNames.spliterator(), false )
+                     .collect( toCollection( () -> using ) );
         return this;
     }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/398a5e8c/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java
index 7401482..0a4b5fa 100644
--- a/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java
+++ b/core/bootstrap/src/main/java/org/apache/zest/bootstrap/builder/ModuleDeclaration.java
@@ -21,14 +21,14 @@ package org.apache.zest.bootstrap.builder;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.StreamSupport;
 import org.apache.zest.bootstrap.Assembler;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.LayerAssembly;
 import org.apache.zest.bootstrap.ModuleAssembly;
 
+import static java.util.stream.Collectors.toList;
 import static org.apache.zest.api.util.Classes.isAssignableFrom;
-import static org.apache.zest.functional.Iterables.filter;
-import static org.apache.zest.functional.Iterables.toList;
 
 /**
  * Provides declared {@link org.apache.zest.api.structure.Module} information that the {@link ApplicationBuilder} can use.
@@ -88,15 +88,14 @@ public class ModuleDeclaration
      * <p>Typically used along {@link org.apache.zest.bootstrap.ClassScanner}.</p>
      * @param assemblerClasses Assembler classes
      * @return This Module declaration
-     * @throws AssemblyException if one of the Class is not an Assembler or unable to instanciate
+     * @throws AssemblyException if one of the Class is not an Assembler or unable to instantiate
      */
     public ModuleDeclaration withAssemblers( Iterable<Class<?>> assemblerClasses )
         throws AssemblyException
     {
-        List<Class<?>> notAssemblers = toList(
-            filter( isAssignableFrom( Assembler.class ).negate(),
-                    assemblerClasses )
-        );
+        List<Class<?>> notAssemblers = StreamSupport.stream( assemblerClasses.spliterator(), false )
+                                                    .filter( isAssignableFrom( Assembler.class ).negate() )
+                                                    .collect( toList() );
         if( !notAssemblers.isEmpty() )
         {
             throw new AssemblyException(

http://git-wip-us.apache.org/repos/asf/zest-java/blob/398a5e8c/core/bootstrap/src/test/java/org/apache/zest/bootstrap/builder/ApplicationBuilderTest.java
----------------------------------------------------------------------
diff --git a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/builder/ApplicationBuilderTest.java b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/builder/ApplicationBuilderTest.java
index a07d92a..e30a3e0 100644
--- a/core/bootstrap/src/test/java/org/apache/zest/bootstrap/builder/ApplicationBuilderTest.java
+++ b/core/bootstrap/src/test/java/org/apache/zest/bootstrap/builder/ApplicationBuilderTest.java
@@ -35,7 +35,6 @@ import org.junit.Test;
 import static java.util.stream.Collectors.toList;
 import static org.apache.zest.bootstrap.ClassScanner.findClasses;
 import static org.apache.zest.bootstrap.ClassScanner.matches;
-import static org.apache.zest.functional.Iterables.filter;
 import static org.hamcrest.core.IsEqual.equalTo;
 import static org.junit.Assert.assertThat;
 
@@ -48,9 +47,10 @@ public class ApplicationBuilderTest
         ApplicationBuilder builder = new ApplicationBuilder( "Build from API test." );
         builder.withLayer( "layer1" ).using( "layer2" ).using( "layer3" );
         builder.withLayer( "layer2" );
-        builder.withLayer( "layer3" ).withModule( "test module" ).
-            withAssemblers( filter( matches( ".*ServiceAssembler" ),
-                                    findClasses( getClass() ).collect( toList() ) ) );
+        builder.withLayer( "layer3" )
+               .withModule( "test module" )
+               .withAssemblers( findClasses( getClass() ).filter( matches( ".*ServiceAssembler" ) )
+                                                         .collect( toList() ) );
         Application application = builder.newApplication();
         Module module = application.findModule( "layer3", "test module" );
         TestService service = module.findService( TestService.class ).get();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/398a5e8c/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ObjectSelection.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ObjectSelection.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ObjectSelection.java
index 3fb146a..951d77f 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ObjectSelection.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ObjectSelection.java
@@ -23,7 +23,6 @@ package org.apache.zest.library.rest.server.api;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import org.apache.zest.functional.Iterables;
 import org.restlet.Request;
 
 /**
@@ -83,11 +82,11 @@ public class ObjectSelection
 
     public List<Object> selection()
     {
-        return Collections.unmodifiableList(selection);
+        return Collections.unmodifiableList( selection );
     }
 
     public Object[] toArray()
     {
-        return Iterables.toArray( Object.class, selection );
+        return selection.toArray( new Object[ selection.size() ] );
     }
 }


[5/5] zest-java git commit: remove core/io usage from tests & helpers in libraries & extensions

Posted by pa...@apache.org.
remove core/io usage from tests & helpers in libraries & extensions


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

Branch: refs/heads/develop
Commit: dc30f4b41497087280ac734d2285123bf2f1f398
Parents: 1a9f685
Author: Paul Merlin <pa...@apache.org>
Authored: Mon Nov 28 19:27:06 2016 +0100
Committer: Paul Merlin <pa...@apache.org>
Committed: Mon Nov 28 19:27:06 2016 +0100

----------------------------------------------------------------------
 .../library/circuitbreaker/CircuitBreakers.java | 45 --------------------
 1 file changed, 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/dc30f4b4/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreakers.java
----------------------------------------------------------------------
diff --git a/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreakers.java b/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreakers.java
index 5ef0af3..e334635 100644
--- a/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreakers.java
+++ b/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreakers.java
@@ -20,57 +20,12 @@
 package org.apache.zest.library.circuitbreaker;
 
 import java.util.function.Predicate;
-import org.apache.zest.io.Output;
-import org.apache.zest.io.Receiver;
-import org.apache.zest.io.Sender;
 
 /**
  * CircuitBreaker helper methods.
  */
 public class CircuitBreakers
 {
-   public static <Item, ReceiverThrowable extends Throwable> Output<Item, ReceiverThrowable> withBreaker( final CircuitBreaker breaker, final Output<Item, ReceiverThrowable> output)
-   {
-      return new Output<Item, ReceiverThrowable>()
-      {
-         @Override
-         public <SenderThrowableType extends Throwable> void receiveFrom(final Sender<? extends Item, SenderThrowableType> sender) throws ReceiverThrowable, SenderThrowableType
-         {
-            output.receiveFrom( new Sender<Item, SenderThrowableType>()
-            {
-               @Override
-               public <ReceiverThrowableType extends Throwable> void sendTo(final Receiver<? super Item, ReceiverThrowableType> receiver) throws ReceiverThrowableType, SenderThrowableType
-               {
-                  // Check breaker first
-                  if (!breaker.isOn())
-                     throw (ReceiverThrowableType) breaker.lastThrowable();
-
-                  sender.sendTo( new Receiver<Item, ReceiverThrowableType>()
-                  {
-                     @Override
-                     public void receive( Item item ) throws ReceiverThrowableType
-                     {
-                        try
-                        {
-                           receiver.receive( item );
-
-                           // Notify breaker that it went well
-                           breaker.success();
-                        } catch (Throwable receiverThrowableType)
-                        {
-                           // Notify breaker of trouble
-                           breaker.throwable( receiverThrowableType );
-
-                           throw (ReceiverThrowableType) receiverThrowableType;
-                        }
-                     }
-                  });
-               }
-            });
-         }
-      };
-   }
-
    /**
     * Allow all throwables that are equal to or subclasses of given list of throwables.
     *