Search in sources :

Example 1 with ManagedCursorStreamProvider

use of org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider in project mule by mulesoft.

the class CursorManager method manage.

/**
 * Becomes aware of the given {@code provider} and returns a replacement provider which is managed by the runtime, allowing for
 * automatic resource handling
 *
 * @param provider the provider to be tracked
 * @param creatorEvent the event that created the provider
 * @return a {@link CursorContext}
 */
public CursorProvider manage(CursorProvider provider, CoreEvent creatorEvent) {
    final BaseEventContext ownerContext = ((BaseEventContext) creatorEvent.getContext()).getRootContext();
    registerEventContext(ownerContext);
    registry.getUnchecked(ownerContext.getId()).addProvider(provider);
    final CursorContext context = new CursorContext(provider, ownerContext);
    if (provider instanceof CursorStreamProvider) {
        return new ManagedCursorStreamProvider(context, this);
    } else if (provider instanceof CursorIteratorProvider) {
        return new ManagedCursorIteratorProvider(context, this);
    }
    throw new MuleRuntimeException(createStaticMessage("Unknown cursor provider type: " + context.getClass().getName()));
}
Also used : BaseEventContext(org.mule.runtime.core.privileged.event.BaseEventContext) ManagedCursorStreamProvider(org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider) CursorStreamProvider(org.mule.runtime.api.streaming.bytes.CursorStreamProvider) ManagedCursorIteratorProvider(org.mule.runtime.core.internal.streaming.object.ManagedCursorIteratorProvider) CursorIteratorProvider(org.mule.runtime.api.streaming.object.CursorIteratorProvider) ManagedCursorStreamProvider(org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) ManagedCursorIteratorProvider(org.mule.runtime.core.internal.streaming.object.ManagedCursorIteratorProvider)

Aggregations

MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)1 CursorStreamProvider (org.mule.runtime.api.streaming.bytes.CursorStreamProvider)1 CursorIteratorProvider (org.mule.runtime.api.streaming.object.CursorIteratorProvider)1 ManagedCursorStreamProvider (org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider)1 ManagedCursorIteratorProvider (org.mule.runtime.core.internal.streaming.object.ManagedCursorIteratorProvider)1 BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)1