public interface StreamingHelper
As you know, when a parameter is resolved to a CursorProvider, the runtime automatically obtains a Cursor
and injects that value instead. However, if that provider is embedded as the value of a Map or an arbitrary pojo,
the runtime can't guess that's the case and go resolve it.
Same thing applies when a component is producing a result. The runtime automatically converts returned InputStream
or PagingProvider instances into CursorProvider ones. However, if such instances are contained in some other
value, that resolution won't happen automatically either.
For these border cases, this class provides some utilities to adapt the providers into
cursors and vice versa
CursorProvider,
CursorStreamProvider,
CursorIteratorProvider| Modifier and Type | Method and Description |
|---|---|
Object |
resolveCursor(Object value)
If the
value is a CursorProvider, a corresponding Cursor is returned. |
Object |
resolveCursorProvider(Object value)
If the
value is a repeatable streaming resource such as InputStream, Cursor,
streaming iterators, etc., then an equivalent CursorProvider is returned. |
<K> Map<K,Object> |
resolveCursorProviders(Map<K,Object> map,
boolean recursive)
Inspects the values of the given
map looking for repeatable streaming resources such as InputStream,
Cursor, streaming iterators, etc., A new equivalent map is returned, except that such values
have been replaced by CursorProvider instances. |
<K> Map<K,Object> |
resolveCursors(Map<K,Object> map,
boolean recursive)
Inspects the values of the given
map looking for instances of CursorProvider. |
<K> Map<K,Object> resolveCursors(Map<K,Object> map, boolean recursive)
map looking for instances of CursorProvider.
A new equivalent map is returned, except that the CursorProvider values have been replaced by
obtained cursors. No side effect is applied on the original map.
A best effort will be made for the returned map to be of the same class as the original one. If that's not possible (most likely because the class doesn't have an accessible default constructor), then the runtime will choose its own map implementation, but guarantying that the iterator order is respected.
If the map contains a value of type Map and recursive is set to true,
then that Map value will also be replaced by a new map which comes from recursively applying this
same method.
<K> Map<K,Object> resolveCursorProviders(Map<K,Object> map, boolean recursive)
map looking for repeatable streaming resources such as InputStream,
Cursor, streaming iterators, etc., A new equivalent map is returned, except that such values
have been replaced by CursorProvider instances. No side effect is applied on the original map.
For Cursor values, the same CursorProvider that already owns that Cursor is used. For other
streaming values, the operation's repeatable streaming strategy will be used. If that strategy doesn't apply
(e.g: the operation returns a PagingProvider but the streaming resource is an InputStream), then the
system's default matching strategy will be used instead.
A best effort will be made for the returned map to be of the same class as the original one. If that's not possible (most likely because the class doesn't have an accessible default constructor), then the runtime will choose its own map implementation, but guarantying that the iterator order is respected.
If the map contains a value of type Map and recursive is set to true,
then that Map value will also be replaced by a new map which comes from recursively applying this
same method.
K - the generic type of the map's keysmap - a Map which may contain streaming valuesrecursive - Whether to also use this method to replace values of type MapMap which streaming values may have been replaced by CursorProvider instances, depending
on the component's configuration.Object resolveCursor(Object value)
value is a CursorProvider, a corresponding Cursor is returned. The same
value is returned otherwise.value - a value which may be a CursorProviderCursor or the input valueObject resolveCursorProvider(Object value)
value is a repeatable streaming resource such as InputStream, Cursor,
streaming iterators, etc., then an equivalent CursorProvider is returned. If the value is not a
repeatable streaming resource or the owning component is configured not to use repeatable streams, then the same
value is returned.
For Cursor values, the same CursorProvider that already owns that Cursor is used. For other
streaming values, the operation's repeatable streaming strategy will be used. If that strategy doesn't apply
(e.g: the operation returns a PagingProvider but the streaming resource is an InputStream), then the
system's default matching strategy will be used instead.
value - a value which may be a repeatable streaming resource.CursorProvider or the same input valueCopyright © 2017 MuleSoft, Inc.. All rights reserved.