Interface Bean<I,​T>

  • Type Parameters:
    G - the group identifier type
    I - the bean identifier type
    T - the bean instance type
    All Superinterfaces:
    AutoCloseable

    public interface Bean<I,​T>
    extends AutoCloseable
    Represents a bean and the group to which it is associated.
    Author:
    Paul Ferraro
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      T acquire()
      Acquires a reference to the bean instance.
      void close()
      Closes any resources used by this bean.
      I getGroupId()
      Returns the identifier of the group to which this bean is associated.
      I getId()
      Returns the identifier of this bean.
      boolean isExpired()
      Indicates whether or not the specified bean is expired.
      boolean isValid()
      Indicates whether this bean was removed.
      boolean release()
      Releases a reference to the bean made via acquire().
      void remove​(RemoveListener<T> listener)
      Removes this bean, notifying the specified listener.
    • Method Detail

      • getId

        I getId()
        Returns the identifier of this bean.
        Returns:
        a unique identifier
      • getGroupId

        I getGroupId()
        Returns the identifier of the group to which this bean is associated.
        Returns:
        a unique identifier of a group
      • acquire

        T acquire()
        Acquires a reference to the bean instance. Every call to acquire() should be paired with a call to release().
        Returns:
        the bean instance
      • release

        boolean release()
        Releases a reference to the bean made via acquire().
        Returns:
        true, if all acquisitions have been released, false otherwise.
      • isExpired

        boolean isExpired()
        Indicates whether or not the specified bean is expired.
        Returns:
        true, if this bean has expired, false otherwise.
      • remove

        void remove​(RemoveListener<T> listener)
        Removes this bean, notifying the specified listener.
        Parameters:
        listener - a remove listener
      • isValid

        boolean isValid()
        Indicates whether this bean was removed.
        Returns:
        false, if this bean was removed, true otherwise.
      • close

        void close()
        Closes any resources used by this bean. A bean should only be closed when all referenced have been released, i.e. release() returned true.
        Specified by:
        close in interface AutoCloseable