001package com.identityworksllc.iiq.common.task; 002 003import com.identityworksllc.iiq.common.Functions; 004import sailpoint.api.SailPointContext; 005import sailpoint.object.Attributes; 006import sailpoint.tools.GeneralException; 007 008import java.util.Iterator; 009import java.util.function.Consumer; 010 011/** 012 * An interface allowing different implementations of object retrievers to be used 013 * with the abstract object iterator task model. 014 * 015 * By default, the task will use {@link BasicObjectRetriever}, which handles a variety 016 * of Sailpoint-friendly retrieval options. 017 * 018 * @param <ItemType> 019 */ 020public interface ObjectRetriever<ItemType> { 021 /** 022 * Returns an iterator over the expected type. The objects returned by the iterator 023 * should be free of association with the top-level context, as they will be invoked 024 * by child contexts. 025 * 026 * @param context The context used to load the objects if needed 027 * @param arguments The arguments to the retrieval 028 * @return An iterator over the desired objects 029 * @throws GeneralException if retrieval fails for some reason 030 */ 031 Iterator<ItemType> getObjectIterator(SailPointContext context, Attributes<String, Object> arguments) throws GeneralException; 032 033 /** 034 * A hook installer method allowing an object retriever and its calling class to 035 * handle termination events together. By default, this does nothing. 036 * 037 * The expected API dance is: 038 * 039 * 1) The calling class invokes this method, passing its own custom consumer. 040 * 2) The calling class invokes getObjectIterator(). 041 * 3) While retrieving objects, the object retriever may make one or more calls to the Consumer to register a termination handler. 042 * 4) If the calling class is terminated, all handlers passed to the Consumer should be invoked. 043 * 044 * @param registar The registration hook, if any 045 */ 046 default void setTerminationRegistrar(Consumer<Functions.GenericCallback> registar) { 047 048 } 049}