Modifier and Type | Method and Description |
---|---|
static CursorStreamProvider |
asCursorProvider(byte[] bytes)
Returns a
CursorStreamProvider which is backed by the given bytes . |
static <T> CursorIteratorProvider |
asCursorProvider(List<T> items)
Returns a
CursorIteratorProvider which is backed by the given items . |
static boolean |
closeQuietly(Cursor cursor)
Closes the given
cursor swallowing any exceptions found. |
static CoreEvent |
consumeRepeatablePayload(CoreEvent event)
If the
event has a repeatable payload (instance of CursorProvider ), then this method returns a new
event which payload has an equivalent, already consumed structure. |
static Object |
streamingContent(Object value,
CursorProviderFactory cursorProviderFactory,
CoreEvent event)
If the
cursorProviderFactory accepts the given value , then the result of invoking
CursorProviderFactory.of(CoreEvent, Object) is returned. |
static Function<CoreEvent,CoreEvent> |
updateEventForStreaming(StreamingManager streamingManager)
Provides a function that updates the payload value of an
CoreEvent by replacing it with a CursorProvider . |
static TypedValue |
updateTypedValueForStreaming(TypedValue value,
CoreEvent event,
StreamingManager streamingManager)
Updates the value a given
TypedValue instance by replacing it with a CursorProvider . |
static TypedValue |
updateTypedValueWithCursorProvider(TypedValue value,
CoreEvent event,
StreamingManager streamingManager)
|
static CoreEvent |
withCursoredEvent(CoreEvent event,
CheckedFunction<CoreEvent,CoreEvent> f)
Executes the given function
f considering that the given event might have a CursorProvider as
payload. |
public static CoreEvent withCursoredEvent(CoreEvent event, CheckedFunction<CoreEvent,CoreEvent> f) throws MuleException
f
considering that the given event
might have a CursorProvider
as
payload. In that case, this method obtains a cursor from the provider and executes the function.
Closing the opened cursor, handling exceptions and return values are all taken care of by this utility method.
event
- an CoreEvent
f
- the function to executeCoreEvent
MuleException
public static Object streamingContent(Object value, CursorProviderFactory cursorProviderFactory, CoreEvent event)
cursorProviderFactory
accepts the given value
, then the result of invoking
CursorProviderFactory.of(CoreEvent, Object)
is returned. Otherwise, the original value
is.value
- a value which may be a repeatable streaming resourcecursorProviderFactory
- a nullable CursorStreamProviderFactory
event
- the event on which the value
was generatedvalue
or a CursorProvider
public static boolean closeQuietly(Cursor cursor)
cursor
swallowing any exceptions found.cursor
- a Cursor
cursor
was closed or notpublic static <T> CursorIteratorProvider asCursorProvider(List<T> items)
CursorIteratorProvider
which is backed by the given items
.
Notice that since the items
data is already fully loaded into memory, this kind of
defeats the purpose of the cursor provider. The purpose of this method is to provide a way to
bridge the given data with the CursorIteratorProvider
abstraction. Possible use cases are
mainly deserialization and testing. Think twice before using this method. Most likely you're
doing something wrong.
Also consider that because the data is already in memory, the cursors will never buffer into disk.
T
- the generic type of the provider's itemsitems
- the items which back the returned providerCursorIteratorProvider
public static CursorStreamProvider asCursorProvider(byte[] bytes)
CursorStreamProvider
which is backed by the given bytes
.
Notice that since the bytes
data is already fully loaded into memory, this kind of
defeats the purpose of the cursor provider. The purpose of this method is to provide a way to
bridge the given data with the CursorStreamProvider
abstraction. Possible use cases are
mainly deserialization and testing. Think twice before using this method. Most likely you're
doing something wrong.
Also consider that because the data is already in memory, the cursors will never buffer into disk.
bytes
- the byte array which backs the returned providerCursorStreamProvider
public static CoreEvent consumeRepeatablePayload(CoreEvent event)
event
has a repeatable payload (instance of CursorProvider
), then this method returns a new
event which payload has an equivalent, already consumed structure. This functionality makes sense for cases like
caching in which the contents of the stream need to survive the completion of the event that generated it.
If the payload is a CursorStreamProvider
, then it will be consumed into a ByteArrayCursorStreamProvider
so that the contents are fully in memory while still keeping repeatable byte streaming semantics.
If the payload is a CursorIteratorProvider
, then the contents will be consumed into a List
.
In any other case, the same input event is returned
event
- an event which might have a repeatable payloadCoreEvent
public static TypedValue updateTypedValueForStreaming(TypedValue value, CoreEvent event, StreamingManager streamingManager)
TypedValue
instance by replacing it with a CursorProvider
.value
- the typed value to updateevent
- the current eventstreamingManager
- the streaming managerinstance
public static Function<CoreEvent,CoreEvent> updateEventForStreaming(StreamingManager streamingManager)
CoreEvent
by replacing it with a CursorProvider
.streamingManager
- the streaming managerCoreEvent
public static TypedValue updateTypedValueWithCursorProvider(TypedValue value, CoreEvent event, StreamingManager streamingManager)
value
- the typed value to updateevent
- the current eventstreamingManager
- the streaming managerinstance
Copyright © 2018. All rights reserved.