@Override public void run() { synchronized (listeners) { Input<TransactionApplicationEvents, RuntimeException> input = Inputs.iterable( Collections.singleton( transactionDomain ) ); for (Output<TransactionApplicationEvents, ? extends Throwable> listener : listeners) { try { input.transferTo( listener ); } catch (Throwable e) { logger.warn( "Could not notify event listener", e ); } } } } } );
/** * 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" ); }
@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<Byte>(); text( output ).transferTo( map( valueSerialization.deserialize( Byte.class ), collection( list ) ) ); assertEquals( byteCollection(), list ); }
Inputs.iterable( Iterables.iterable( unitOfWorkDomainValue ) ).transferTo( eventOutput );