Interface HttpScope


  • public interface HttpScope
    An attachment scope for use by an authentication mechanism.

    Different scopes may be available to share Objects e.g. Application, Session, Connection.

    Author:
    Darran Lofthouse
    • Method Summary

      All Methods Instance Methods Default Methods 
      Modifier and Type Method Description
      default boolean changeID()
      Change the ID of this scope.
      default boolean create()
      Create this scope.
      default boolean exists()
      Tests whether this scope exists.
      default Object getAttachment​(String key)
      Get the attachment previously associated with the key specified on this scope.
      default <T> T getAttachment​(String key, Class<T> type)
      Get the attachment previously associated with the key specified on this scope and cast it to the type specified.
      default String getID()
      Get the ID of this scope or (@code null} if IDs are not supported for this scope or the scope doesn't currently exist.
      default InputStream getResource​(String path)
      Get the resource associated with the path specified.
      default boolean invalidate()
      Invalidate this scope.
      default void registerForNotification​(Consumer<HttpScopeNotification> notificationConsumer)
      Register a notification consumer to receive notifications from this scope.
      default void setAttachment​(String key, Object value)
      Set the named attribute on this scope, setting to null will clear any value previously set for this key.
      default boolean supportsAttachments()
      Tests whether this scope support attachments.
      default boolean supportsChangeID()
      Is changing the ID of the scope supported?
      default boolean supportsInvalidation()
      Is invalidation supported for this scope?
      default boolean supportsNotifications()
      Tests whether this scope support registration to receive notifications.
      default boolean supportsResources()
      Tests whether this scope support access to scope specific resources.
    • Method Detail

      • getID

        default String getID()
        Get the ID of this scope or (@code null} if IDs are not supported for this scope or the scope doesn't currently exist.
        Returns:
        the ID of this scope or (@code null} if IDs are not supported for this scope or the scope doesn't currently exist.
      • exists

        default boolean exists()
        Tests whether this scope exists.
        Returns:
        true if this scope exists. Otherwise, false
      • create

        default boolean create()
        Create this scope.
        Returns:
        true if the scope was created. Otherwise, false indicating that this scope was already created or that creation is not support.
      • supportsAttachments

        default boolean supportsAttachments()
        Tests whether this scope support attachments.
        Returns:
        true if this scope supports attachments, false otherwise
      • setAttachment

        default void setAttachment​(String key,
                                   Object value)
        Set the named attribute on this scope, setting to null will clear any value previously set for this key.
        Parameters:
        key - the key to use to store the attachment.
        value - the value to store with the key or null to clear any previously stored attachment.
        Throws:
        UnsupportedOperationException - if attachments are not supported.
      • getAttachment

        default Object getAttachment​(String key)
        Get the attachment previously associated with the key specified on this scope.
        Parameters:
        key - the key used to store the attachment on this scope.
        Returns:
        the value associated with the scope or null if no association exists.
        Throws:
        UnsupportedOperationException - if attachments are not supported.
      • getAttachment

        default <T> T getAttachment​(String key,
                                    Class<T> type)
        Get the attachment previously associated with the key specified on this scope and cast it to the type specified. This method will only return a value if the attachment exists AND can be cast to the desired type, otherwise it returns null.
        Parameters:
        key - the key used to store the attachment on this scope.
        type - the desired type of the attachment.
        Returns:
        the value associated with the scope or null if no association exists or if it could not be converted to the requested type.
        Throws:
        UnsupportedOperationException - if attachments are not supported.
      • supportsInvalidation

        default boolean supportsInvalidation()
        Is invalidation supported for this scope?
        Returns:
        true if this scope supports invalidation, false otherwise.
      • invalidate

        default boolean invalidate()
        Invalidate this scope.
        Returns:
        true if invalidation was successful, false otherwise.
      • supportsChangeID

        default boolean supportsChangeID()
        Is changing the ID of the scope supported?
        Returns:
        true if this scope supports changing the ID, false otherwise.
      • changeID

        default boolean changeID()
        Change the ID of this scope.
        Returns:
        true if the change was successful, false otherwise.
      • supportsResources

        default boolean supportsResources()
        Tests whether this scope support access to scope specific resources.
        Returns:
        true if this scope supports access to scope specific resources, false otherwise.
      • getResource

        default InputStream getResource​(String path)
        Get the resource associated with the path specified.
        Parameters:
        path - the path to the resource.
        Returns:
        the InputStream of the resource or null if resources is not supported or the specified resource is not found.
      • supportsNotifications

        default boolean supportsNotifications()
        Tests whether this scope support registration to receive notifications.
        Returns:
        true if this scope supports registration for notifications, false otherwise.
      • registerForNotification

        default void registerForNotification​(Consumer<HttpScopeNotification> notificationConsumer)
        Register a notification consumer to receive notifications from this scope.
        Parameters:
        notificationConsumer - the consumer to receive notifications from this scope.