use of org.mule.runtime.core.internal.streaming.object.ManagedCursorIteratorProvider 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()));
}
Aggregations