apiman/apiman — pull request #30 by msavy (2014-11-17 17:35:41+00:00)
Title: Major refactoring to support streamed handling and stateful policies

Generic handlers for three part streamed operations (head, body, end).

Add interfaces that allow implementation detail of stream handlers to be hidden
from users - helps prevent accidental breakage/misuse.

Handler for executing a request/response sequence: StreamHandler in
PolicyRequestExecutor indicates when it is safe to start transmitting chunks.

Added generic ApimanBuffer, for each platform to implement. ApimanBuffer #getNative is a raw Object for now, so caveat utilitor.

Changed Policy factory to instantiate new policies and load config.

Added Iterator that can be reset to avoid unnecessary object creation.

Added variety of tests for the policy chain, including handlers, buffer ordering, etc.

Refactor IAsyncHandler so we don't always need to generate and parse an IAsyncResult.
Often a bare object is appropriate and more efficient.
IAsyncResultHandler replaces this, and IAsyncHandler is now a bare object.

Refactor policy failure and error handling, remove any template/todo code.

Add new tests to cover additional cases: an area we can still improve.

NLS annotations.

Updated code documentation.

Remove body InputStream and associated get/set.

Nuke the Future.

Abortable interface provides #abort signal mechanism, for instance to Streams, Policies, etc.

Explicit signalling mechanisms in ISignal* classes to indicate when transmission is safe to begin.

In Chain & Policy it fires after policy failure or exception, allowing them to abort any ongoing actions.

Delete unused IPolicyChainHandler.

Remove IPolicyChain/IPolicyChainImpl & move functionality into RequestExecutor.

Remove redundant public modifier on interfaces & add headers where appropriate.

Correct error handling to ensure policies can abort without exceptions (possible legitimate alternative is to put a result into #doApply that indicates success/PolicyFailure, but there may be performance tradeoffs with approach).

Change Policy to be abstract class, with default pass-through behaviour which should be overridden by implementors interested in.

Refactor to greatly simplify and centralise error paths. Cleans up code nicely.

Add tests for error and failure handling.