Class ObjectRetriever


  • public class ObjectRetriever
    extends Object
    Generated class for retrieving/dispatching objects of a specific type.

    This class can be used for:

    • Locating objects when their type and unique-Id are known;
    • Type-safe dispatching based on an object whose type and unique-Id are known;
    • Type-safe dispatch based on the type of an object.
    • Constructor Detail

      • ObjectRetriever

        public ObjectRetriever​(SchedulerSession initSession)
        Construct an object retriever that will use the supplied session. The session can be closed by invoking the close() method.
        Parameters:
        initSession - Session to use for retrieving objects.
    • Method Detail

      • close

        @Deprecated
        public void close()
        Deprecated.
        Mark this object retriever as no longer being used. This involves closing the session that was supplied to the constructor.
      • lookupSchedulerEntity

        @Deprecated
        public SchedulerEntity lookupSchedulerEntity​(String objectType,
                                                     Long uniqueId)
        Deprecated.
        This method is deprecated, please use SchedulerSession.getSchedulerEntityByObjectTypeUniqueId(String, Long) instead.

        Lookup an object that inherits from SchedulerEntity, given its concrete-type and uniqueId. For an object to be returned, it must:

        • Be of the supplied concrete-type;
        • Have the supplied unique-id;
        • Be visible to the user that owns the session.
        If all of these conditions are not met, null is returned.
        Parameters:
        objectType - Concrete-type of the object to locate.
        uniqueId - Unique-ID of the object being sought.
        Returns:
        The object that matches these characters, or null if it could not be found.
      • callbackSchedulerEntity

        public void callbackSchedulerEntity​(String objectType,
                                            Long uniqueId,
                                            ConcreteObjectCallback callback)
                                     throws com.redwood.scheduler.api.exception.CallbackException
        Lookup an object that inherits from SchedulerEntity, given its concrete-type and uniqueId, and invoke a callback with the object. The callback must supply typed methods for each concrete class that inherits from SchedulerEntity, which can then implement behavior based on the type of the object in a type-safe manner.

        In locating the object, the same conditions as for lookupSchedulerEntity(String,Long) apply. If the object cannot be located, no action is taken.

        Parameters:
        objectType - Concrete-type of the object to locate.
        uniqueId - Unique-ID of the object being sought.
        callback - Callback to invoke with the located object.
        Throws:
        com.redwood.scheduler.api.exception.CallbackException - This means the callback threw an exception.
      • callbackSchedulerEntity

        public static void callbackSchedulerEntity​(SchedulerSession session,
                                                   String objectType,
                                                   Long uniqueId,
                                                   ConcreteObjectCallback callback)
                                            throws com.redwood.scheduler.api.exception.CallbackException
        Lookup an object and invoke a callback with it, similar to callbackSchedulerEntity(String,Long,ConcreteObjectCallback), but using the supplied session instead.
        Parameters:
        session - The session to use to locate the object.
        objectType - Concrete-type of the object to locate.
        uniqueId - Unique-ID of the object being sought.
        callback - Callback to invoke with the located object.
        Throws:
        com.redwood.scheduler.api.exception.CallbackException - This means the callback threw an exception.
      • callbackSchedulerEntity

        public static void callbackSchedulerEntity​(SchedulerEntity schedulerEntity,
                                                   ConcreteObjectCallback callback)
                                            throws com.redwood.scheduler.api.exception.CallbackException
        Dispatch to an appropriate callback, based on the type of the object. The callback must supply typed methods for each concrete class that inherits from SchedulerEntity, which can then implement behavior based on the type of the object in a type-safe manner.
        Parameters:
        schedulerEntity - Object to dispatch.
        callback - Callback to invoke with the located object.
        Throws:
        com.redwood.scheduler.api.exception.CallbackException - This means the callback threw an exception.