Return-Path: X-Original-To: apmail-zest-commits-archive@minotaur.apache.org Delivered-To: apmail-zest-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DEFA4186C2 for ; Mon, 21 Sep 2015 15:17:04 +0000 (UTC) Received: (qmail 7367 invoked by uid 500); 21 Sep 2015 15:17:04 -0000 Delivered-To: apmail-zest-commits-archive@zest.apache.org Received: (qmail 7227 invoked by uid 500); 21 Sep 2015 15:17:04 -0000 Mailing-List: contact commits-help@zest.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zest.apache.org Delivered-To: mailing list commits@zest.apache.org Received: (qmail 7053 invoked by uid 99); 21 Sep 2015 15:17:04 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Sep 2015 15:17:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 0218BC08AC for ; Mon, 21 Sep 2015 15:17:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.301 X-Spam-Level: **** X-Spam-Status: No, score=4.301 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RDNS_NONE=2.5, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id KpV7bvwDxQwW for ; Mon, 21 Sep 2015 15:16:47 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (unknown [209.188.14.139]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTP id A962F2306A for ; Mon, 21 Sep 2015 15:16:32 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 7D9A2E0AC1 for ; Mon, 21 Sep 2015 15:16:32 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 5EFE73A0250 for ; Mon, 21 Sep 2015 15:16:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1704315 [14/17] - in /zest/site: content/ content/java/2.1/ content/java/2.1/js/ content/java/latest/ content/java/latest/js/ src/ Date: Mon, 21 Sep 2015 15:16:12 -0000 To: commits@zest.apache.org From: paulmerlin@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150921151632.5EFE73A0250@svn01-us-west.apache.org> Modified: zest/site/content/java/latest/howto-use-io.html URL: http://svn.apache.org/viewvc/zest/site/content/java/latest/howto-use-io.html?rev=1704315&r1=1704314&r2=1704315&view=diff ============================================================================== --- zest/site/content/java/latest/howto-use-io.html (original) +++ zest/site/content/java/latest/howto-use-io.html Mon Sep 21 15:15:15 2015 @@ -66,7 +66,7 @@ })(); -

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 +

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 @@ -102,7 +102,7 @@ what the possible pieces could be:

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:

Table 14. Artifact

Group IDArtifact IDVersion

org.qi4j.core

org.qi4j.core.runtime

2.1


See the Depend on Zest™ in your build tutorial for details.

Once theses parts were identified it was mostly just a matter of putting interfaces on these pieces, and making sure +on Core API, Core SPI, Core Bootstrap and Core Functional & I/O APIs:

Table 14. Artifact

Group IDArtifact IDVersion

org.qi4j.core

org.qi4j.core.runtime

2.1


See the Depend on Zest™ in your build 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:

public interface Input<T, SenderThrowableType extends Throwable>
 {
     <ReceiverThrowableType extends Throwable> void transferTo( Output<? super T, ReceiverThrowableType> output )
@@ -116,7 +116,7 @@ throw SQLException and the output IOExce
 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:

public interface Output<T, ReceiverThrowableType extends Throwable>
 {
-[...snip...]
+  [...snip...]
 
     <SenderThrowableType extends Throwable> void receiveFrom( Sender<? extends T, SenderThrowableType> sender )
         throws ReceiverThrowableType, SenderThrowableType;
@@ -126,7 +126,7 @@ whatever resources it needs to write to,
 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:

public interface Sender<T, SenderThrowableType extends Throwable>
 {
-[...snip...]
+  [...snip...]
 
     <ReceiverThrowableType extends Throwable> void sendTo( Receiver<? super T, ReceiverThrowableType> receiver )
         throws ReceiverThrowableType, SenderThrowableType;
@@ -134,7 +134,7 @@ not the case.

Next we have 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:

public interface Receiver<T, ReceiverThrowableType extends Throwable>
 {
-[...snip...]
+  [...snip...]
 
     void receive( T item )
         throws ReceiverThrowableType;

Modified: zest/site/content/java/latest/js/progressive-enhancement.js
URL: http://svn.apache.org/viewvc/zest/site/content/java/latest/js/progressive-enhancement.js?rev=1704315&r1=1704314&r2=1704315&view=diff
==============================================================================
--- zest/site/content/java/latest/js/progressive-enhancement.js (original)
+++ zest/site/content/java/latest/js/progressive-enhancement.js Mon Sep 21 15:15:15 2015
@@ -143,7 +143,7 @@ $( document ).ready( function($){
             case "Overview":
                 $dt.attr( "style", "margin-bottom: 24px" );
             // Tutorials
-            case "Zest\u2122 in 2 hours":
+            case "Zest\u2122 in 30 minutes":
             case "Leverage Properties":
             case "Use I/O API":
                 $dt.attr( "style", "margin-bottom: 24px" );

Modified: zest/site/content/java/latest/lang-groovy.html
URL: http://svn.apache.org/viewvc/zest/site/content/java/latest/lang-groovy.html?rev=1704315&r1=1704314&r2=1704315&view=diff
==============================================================================
--- zest/site/content/java/latest/lang-groovy.html (original)
+++ zest/site/content/java/latest/lang-groovy.html Mon Sep 21 15:15:15 2015
@@ -66,7 +66,7 @@
   })();
  
 
-  

Groovy Scripting

code

docs

tests

Groovy Scripting Library

Table 22. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.lang-groovy

2.1


The Groovy Scripting Library is a Generic mixin that implements interfaces by delegating to Groovy code from classpath resources.

But before looking at how to use the Scripting library we’ll see t hat you don’t need this library at all if you simply need to use Groovy classes as Fragments. +

Groovy Scripting

code

docs

tests

Groovy Scripting Library

Table 22. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.lang-groovy

2.1


The Groovy Scripting Library is a Generic mixin that implements interfaces by delegating to Groovy code from classpath resources.

But before looking at how to use the Scripting library we’ll see t hat you don’t need this library at all if you simply need to use Groovy classes as Fragments. Then we’ll see how to use Groovy class scripts and method scripts.

All examples below are based on this type:

public interface HelloSpeaker
 {
     String sayHello( String name );

Modified: zest/site/content/java/latest/lang-javascript.html
URL: http://svn.apache.org/viewvc/zest/site/content/java/latest/lang-javascript.html?rev=1704315&r1=1704314&r2=1704315&view=diff
==============================================================================
--- zest/site/content/java/latest/lang-javascript.html (original)
+++ zest/site/content/java/latest/lang-javascript.html Mon Sep 21 15:15:15 2015
@@ -66,7 +66,7 @@
   })();
  
 
-  

Javascript Scripting

code

docs

tests

The Javascript Scripting Library allows Mixin methods to be implemented in Javascript and loaded dynamically on first use.

Table 23. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.lang-javascript

2.1


The Javascript Scripting Library is a Generic mixin class that implements +

Javascript Scripting

code

docs

tests

The Javascript Scripting Library allows Mixin methods to be implemented in Javascript and loaded dynamically on first use.

Table 23. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.lang-javascript

2.1


The Javascript Scripting Library is a Generic mixin class that implements Composite interfaces by delegating to JavaScript functions using Rhino. Each method in an interface is declared as a JS function in a file located in classpath with the name "<interface>.<method>.js", where the interface name Modified: zest/site/content/java/latest/lang-scala.html URL: http://svn.apache.org/viewvc/zest/site/content/java/latest/lang-scala.html?rev=1704315&r1=1704314&r2=1704315&view=diff ============================================================================== --- zest/site/content/java/latest/lang-scala.html (original) +++ zest/site/content/java/latest/lang-scala.html Mon Sep 21 15:15:15 2015 @@ -66,7 +66,7 @@ })(); -

Scala Support

code

docs

tests

The Scala Support Library allows Fragments and Composites to be written as Scala traits.

Table 24. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.lang-scala

2.1


The Scala Support Library is a Generic mixin class that implements Composites by delegating to Scala traits.

Composition

Example mixin declaration:

trait HelloWorldMixin2
+  

Scala Support

code

docs

tests

The Scala Support Library allows Fragments and Composites to be written as Scala traits.

Table 24. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.lang-scala

2.1


The Scala Support Library is a Generic mixin class that implements Composites by delegating to Scala traits.

Composition

Example mixin declaration:

trait HelloWorldMixin2
 {
   def sayHello(@MaxLength(10) name: String ): String = "Hello " + name
 }

Modified: zest/site/content/java/latest/library-alarm.html
URL: http://svn.apache.org/viewvc/zest/site/content/java/latest/library-alarm.html?rev=1704315&r1=1704314&r2=1704315&view=diff
==============================================================================
--- zest/site/content/java/latest/library-alarm.html (original)
+++ zest/site/content/java/latest/library-alarm.html Mon Sep 21 15:15:15 2015
@@ -74,7 +74,7 @@ clear view of what is going on in a plan
 don’t. Very little thought has been spent on what happens when many independent systems interact and what the
 consequences are to other systems when one fails. The Alarm Point concepts becomes a natural fit for the enterprise
 world of today, where Alarm Points allows for fine-grained notification and view into the health of one or more
-systems.

In Zest, we are building upon this powerful abstraction, from decades of field experience.

Table 25. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.alarm

2.1


Overview

An Alarm Point is of an A larm Class and of an Alarm Category. The Alarm Class defines the severity of the +systems.

In Zest, we are building upon this powerful abstraction, from decades of field experience.

Table 25. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.alarm

2.1


Overview

An Alarm Point is of an A larm Class and of an Alarm Category. The Alarm Class defines the severity of the Alarm Point and the Alarm Category defines which part of the system it belongs to. Alarm Category can be extended by the developer, and the package contains the SimpleAlarmCategory as an example, where a Description property has been added.

An Alarm Point also has a System Name, which should be the subsystem or application name.

Alarm Points are triggered and an Alarm Trigger may cause the Alarm Status to change. IF, and only if, the @@ -88,18 +88,18 @@ provide an Id private AlarmProxy.Factory factory; private AlarmProxy myAlarmPoint; -[...snip...] + [...snip...] @Override public void assemble( ModuleAssembly module ) throws AssemblyException { new AlarmSystemAssembler().assemble( module ); - [...snip...] + [...snip...] myAlarmPoint = factory.create( "This Alarm Identity", "ProActiveCRM", "Sales", AlarmClass.B ); myAlarmPoint.history().maxSize().set( 20 ); - [...snip...] + [...snip...] myAlarmPoint.activate();

Alarm Models

The Zest™ Alarm library comes with 3 Alarm Models which should be sufficient for most uses. These are based on decades Modified: zest/site/content/java/latest/library-circuitbreaker.html URL: http://svn.apache.org/viewvc/zest/site/content/java/latest/library-circuitbreaker.html?rev=1704315&r1=1704314&r2=1704315&view=diff ============================================================================== --- zest/site/content/java/latest/library-circuitbreaker.html (original) +++ zest/site/content/java/latest/library-circuitbreaker.html Mon Sep 21 15:15:15 2015 @@ -91,37 +91,37 @@ tripping it should be possible to expose There is a standard implementation of the Availability interface that delegates to a circuit breaker and the Enabled configuration flag, which is what we’d suspect will be used in most cases where external systems -are invoked.

Table 26. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.circuitbreaker

2.1


Direct usage

The CircuitBreaker can be used directly, even without using anything else from the Zest™ SDK.

Here is a code snippet that demonstrate how to create a Circ uitBreaker and how it behave:

// Create a CircuitBreaker with a threshold of 3, a 250ms timeout, allowing IllegalArgumentExceptions
+are invoked.

Table 26. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.circuitbreaker

2.1


Direct usage

The CircuitBreaker can be used directly, even without using anything else from the Zest™ SDK.

Here is a code snippet that demonstrate how to create a Circ uitBreaker and how it behave:

// Create a CircuitBreaker with a threshold of 3, a 250ms timeout, allowing IllegalArgumentExceptions
 CircuitBreaker cb = new CircuitBreaker( 3, 250, CircuitBreakers.in( IllegalArgumentException.class ) );
 
-[...snip...]
+  [...snip...]
 
 // Service levels goes down but does not cause a trip
 cb.throwable( new IOException() );
 
-[...snip...]
+  [...snip...]
 
 // Service level goes down and causes a trip
 cb.throwable( new IOException() );
 cb.throwable( new IOException() );
 
-[...snip...]
+  [...snip...]
 
 // Turn on the CB again
 cb.turnOn();
 
-[...snip...]
+  [...snip...]
 
 // Service levels goes down and causes a trip
 cb.throwable( new IOException() );
 cb.throwable( new IOException() );
 cb.throwable( new IOException() );
 
-[...snip...]
+  [...snip...]
 
 // Wait until timeout
 
-[...snip...]
+  [...snip...]
 
 // CircuitBreaker is back on
 
@@ -137,7 +137,7 @@ update the circuit breaker on annotated
 {
     module.services( TestService.class ).setMetaInfo( new CircuitBreaker() );
 }
-[...snip...]
+  [...snip...]
 
 public interface TestService
         extends AbstractBreakOnThrowable, ServiceComposite
@@ -149,7 +149,7 @@ public interface TestService
     @BreaksCircuitOnThrowable
     void throwingMethod();
 
-    [...snip...]
+      [...snip...]
 
 }
 

Remember to annotate methods which when they throw throwables should cause circuit breakers to trip and go back on @@ -158,7 +158,7 @@ Note that if you already extends ServiceCircuitBreaker.

Here is how it goes:

public void assemble( ModuleAssembly module )
         throws AssemblyException
 {
-[...snip...]
+  [...snip...]
 
     // JMX Library
     module.importedServices( MBeanServer.class ).

Modified: zest/site/content/java/latest/library-constraints.html
URL: http://svn.apache.org/viewvc/zest/site/content/java/latest/library-constraints.html?rev=1704315&r1=1704314&r2=1704315&view=diff
==============================================================================
--- zest/site/content/java/latest/library-constraints.html (original)
+++ zest/site/content/java/latest/library-constraints.html Mon Sep 21 15:15:15 2015
@@ -69,9 +69,9 @@
   

Constraints

code

docs

tests

The Constraints library provide a bunch of often used Constraints based on the Zest™ Constraints api described in Constraint.

Remember that you are not limited to constraints presents in this library, you are encouraged to write your own constraints. See Create a Constraint -or take a look at this library source code to learn how to write your own.

Table 27. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.constraints

2.1


Usage

You can use theses constraints on Properties or on method arguments. +or take a look at this library source code to learn how to write your own.

Table 27. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.constraints

2.1


Usage

You can use theses constraints on Properties or on method arguments. Here are some examples:

import org.qi4j.library.constraints.annotation.*;
-[...snip...]
+  [...snip...]
 
 @Contains( "foo" ) Property<String> containsString();
 

Modified: zest/site/content/java/latest/library-conversion.html
URL: http://svn.apache.org/viewvc/zest/site/content/java/latest/library-conversion.html?rev=1704315&r1=1704314&r2=1704315&view=diff
==============================================================================
--- zest/site/content/java/latest/library-conversion.html (original)
+++ zest/site/content/java/latest/library-conversion.html Mon Sep 21 15:15:15 2015
@@ -66,7 +66,7 @@
   })();
  
 
-  

Conversion - DEPRECATED

code

docs

tests

The Conversion Library provides support for converting composite types.

Table 28. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.conversion

2.1


DEPRECATED

This functional ity is now present in UnitOfWork as +

Conversion - DEPRECATED

code

docs

tests

The Conversion Library provides support for converting composite types.

Table 28. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.conversion

2.1


DEPRECATED

This functional ity is now present in UnitOfWork as the two methods toEntity() and toValue(). Since this library was written assocations of all kinds are now fully supported in Values.

Entities to Values

To convert Entities to Values, use the EntityToValueService. It is easily assembled:

new EntityToValueAssembler().assemble( module );
 

Let’s say we have an interface defining state:

public interface PersonState
@@ -96,7 +96,7 @@ public interface PersonEntity
     ManyAssociation<PersonEntity> children();
 
 }
-[...snip...]
+  [...snip...]
 
 public static abstract class PersonMixin
     implements PersonEntity
@@ -104,7 +104,7 @@ public static abstract class PersonMixin
 
     @This
     private PersonState state;
-    [...snip...]
+      [...snip...]
 
 }
 

And a ValueComposite extending this very same state;

public interface PersonValue

Modified: zest/site/content/java/latest/library-eventsourcing.html
URL: http://svn.apache.org/viewvc/zest/site/content/java/latest/library-eventsourcing.html?rev=1704315&r1=1704314&r2=1704315&view=diff
==============================================================================
--- zest/site/content/java/latest/library-eventsourcing.html (original)
+++ zest/site/content/java/latest/library-eventsourcing.html Mon Sep 21 15:15:15 2015
@@ -69,8 +69,8 @@
   

Event Sourcing

code

docs

tests

The Event Sourcing Library supports generating, storing and replaying two types of events: application-events and domain-events.

Application events are bound to Usecase and are produced by execution of specific methods (ones with ApplicationEvent as their first parameter). Each application event holds information about Usecase, method name and JSON serialized values of method parameters.

Domain events are bound to entity instances and are produced by execution of annotated (see @DomainEvent) methods that belongs to EntityComposite. Each domain event (see DomainEventValue) holds information about entity type, identity, method name and JSON serialized values of method parameters.

Both application and domain events are captured during UnitOfWork lifetime and are stored in EventStore after successfully completed UnitOfWork as collection together (see UnitOfWorkDomainEventsValue and TransactionApplicationEvents).

There is support for replaying events. -When events are replayed the same code is executed but no new events are generated.

There are helper classes that enables a service to easily track events feed, and for domain events there is EventRouter that allow to specify specification→receiver routes.

Table 29. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.eventsourcing

2.1


JDBM ba cked store

EventStore supports indexed and streamed access to events feed. -There is in-memory and JDBM backed implementations.

code

docs

tests

Table 30. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.eventsourcing-jdbm

2.1


REST access

For remote access to feed there i s eventsourcing-rest library that exposes events as Atom feeds.

code

docs

tests

Table 31. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.eventsourcing-rest

2.1


Application Events

Assembly is done as follows:

new EventsourcingAssembler()
+When events are replayed the same code is executed but no new events are generated.

There are helper classes that enables a service to easily track events feed, and for domain events there is EventRouter that allow to specify specification→receiver routes.

Table 29. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.eventsourcing

2.1


JDBM ba cked store

EventStore supports indexed and streamed access to events feed. +There is in-memory and JDBM backed implementations.

code

docs

tests

Table 30. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.eventsourcing-jdbm

2.1


REST access

For remote access to feed there i s eventsourcing-rest library that exposes events as Atom feeds.

code

docs

tests

Table 31. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.eventsourcing-rest

2.1


Application Events

Assembly is done as follows:

new EventsourcingAssembler()
         .withApplicationEvents()
         .withCurrentUserFromUOWPrincipal()
         .assemble(module);