Interface NamingProvider

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
HttpNamingProvider, RemoteNamingProvider

public interface NamingProvider extends AutoCloseable
A provider for a single naming scheme. Each implementation of a naming provider has different characteristics.
Author:
David M. Lloyd
  • Method Details

    • getProviderEnvironment

      ProviderEnvironment getProviderEnvironment()
      Get the provider environment.
      Returns:
      the provider environment (must not be null)
    • getPeerIdentityForNaming

      default PeerIdentity getPeerIdentityForNaming() throws NamingException
      Get a peer identity to use for context operations. The identity may be fixed or it may vary, depending on the context configuration. If the provider has multiple locations, a location is randomly selected.
      Returns:
      the peer identity to use (must not be null)
      Throws:
      NamingException - if connecting, authenticating, or re-authenticating the peer failed
    • getPeerIdentityForNamingUsingRetry

      default PeerIdentity getPeerIdentityForNamingUsingRetry(RetryContext context) throws NamingException
      Get a peer identity to use for context operations, retrying on failure. The identity may be fixed or it may vary, depending on the context configuration. If the provider has multiple locations, a location is randomly selected. If the retry context is null, a retry will not occur.
      Parameters:
      context - the retry context for storing state required when retrying
      Returns:
      the peer identity to use (must not be null)
      Throws:
      NamingException - if connecting, authenticating, or re-authenticating the peer failed
    • throwNoMoreDestinationsException

      default void throwNoMoreDestinationsException(RetryContext context) throws NamingException
      Throws either an ExhaustedDestinationsException utilizing the information passed in the specified RetryContext, or an explicit exception mandated by the context.
      Parameters:
      context - the current retry context of this invocation
      Throws:
      ExhaustedDestinationsException - if no explicit exception is specified
      NamingException - if explicity required
      RuntimeException - if explicity required
    • getPeerIdentityForNaming

      PeerIdentity getPeerIdentityForNaming(URI location) throws NamingException
      Get the peer identity to use for context operations for the specified location. The identity may be fixed or it may vary, depending on the context configuration. The location should be from the list returned by ProviderEnvironment.getProviderUris().
      Parameters:
      location - a location from ProviderEnvironment.getProviderUris() (must not be null)
      Returns:
      the peer identity to use (must not be null)
      Throws:
      NamingException - if connecting, authenticating, or re-authenticating the peer failed
    • getCurrentNamingProvider

      static NamingProvider getCurrentNamingProvider()
      Get the current naming provider being used for the current deserialization operation.
      Returns:
      the current naming provider, or null if no provider-related deserialization is occurring
    • performAction

      default <T, U, R> R performAction(BiFunction<T,U,R> function, T arg1, U arg2)
      Perform an action under the current naming provider.
      Type Parameters:
      T - the first argument type
      U - the second argument type
      R - the function return type
      Parameters:
      function - the function to apply (must not be null)
      arg1 - the first argument
      arg2 - the second argument
      Returns:
      the function return value
    • performExceptionAction

      default <T, U, R, E extends Exception> R performExceptionAction(ExceptionBiFunction<T,U,R,E> function, T arg1, U arg2) throws E
      Perform an action under the current naming provider.
      Type Parameters:
      T - the first argument type
      U - the second argument type
      R - the function return type
      E - the function exception type
      Parameters:
      function - the function to apply (must not be null)
      arg1 - the first argument
      arg2 - the second argument
      Returns:
      the function return value
      Throws:
      E - if the function throws an exception of the given type
    • performExceptionAction

      default <T, R> R performExceptionAction(NamingOperation<T,R> function, RetryContext contextOrNull, Name name, T param) throws NamingException
      Perform an action under the current naming provider.
      Type Parameters:
      T - the first argument type
      R - the function return type
      Parameters:
      function - the function to apply (must not be null)
      Returns:
      the function return value
      Throws:
      NamingException
    • close

      default void close() throws NamingException
      Close the provider. This method is called when the corresponding InitialContext is closed. This method should be idempotent.
      Specified by:
      close in interface AutoCloseable
      Throws:
      NamingException - if an error occurred while closing this provider