Class AbstractHttpDiscoveryRestClientDecorator<B extends HttpDiscoveryRestClient<B>>

java.lang.Object
org.refcodes.rest.AbstractHttpRestClientDecorator<B>
org.refcodes.rest.AbstractHttpDiscoveryRestClientDecorator<B>
All Implemented Interfaces:
org.refcodes.component.Closable, org.refcodes.component.Configurable<HttpDiscoveryContext>, org.refcodes.component.ConnectionComponent<org.refcodes.web.HttpClientContext>, org.refcodes.component.ConnectionOpenable<org.refcodes.web.HttpClientContext>, org.refcodes.component.ConnectionStatusAccessor, org.refcodes.component.Destroyable, org.refcodes.component.Destroyable.DestroyAutomaton, org.refcodes.component.Initializable, org.refcodes.component.Initializable.InitializeAutomaton, org.refcodes.component.InitializedAccessor, org.refcodes.component.LifecycleComponent, org.refcodes.component.LifecycleComponent.LifecycleAutomaton, org.refcodes.component.LifecycleStatusAccessor, org.refcodes.component.LinkComponent, org.refcodes.component.Openable, org.refcodes.component.Openable.OpenBuilder<HttpRestClient>, org.refcodes.component.OpenedAccessor, org.refcodes.component.Pausable, org.refcodes.component.Pausable.PauseAutomaton, org.refcodes.component.Resumable, org.refcodes.component.Resumable.ResumeAutomaton, org.refcodes.component.RunningAccessor, org.refcodes.component.Startable, org.refcodes.component.Startable.StartAutomaton, org.refcodes.component.Stoppable, org.refcodes.component.Stoppable.StopAutomaton, HttpDiscovery<B>, HttpDiscoveryRestClient<B>, HttpDiscoveryUrlAccessor, HttpDiscoveryUrlAccessor.HttpDiscoveryUrlBuilder<B>, HttpDiscoveryUrlAccessor.HttpDiscoveryUrlMutator, HttpDiscoveryUrlAccessor.HttpDiscoveryUrlProperty, HttpRestClient, RestClient, RestDeleteClient, RestGetClient, RestPostClient, RestPutClient, RestRequestClient, RestRequestHandler, org.refcodes.runtime.RequestCorrelation<RestClient>, org.refcodes.runtime.SessionCorrelation<RestClient>, org.refcodes.security.TrustStoreDescriptorAccessor, org.refcodes.security.TrustStoreDescriptorAccessor.TrustStoreDescriptorBuilder<HttpRestClient>, org.refcodes.security.TrustStoreDescriptorAccessor.TrustStoreDescriptorMutator, org.refcodes.security.TrustStoreDescriptorAccessor.TrustStoreDescriptorProperty, org.refcodes.web.BaseUrlAccessor, org.refcodes.web.BaseUrlAccessor.BaseUrlBuilder<HttpRestClient>, org.refcodes.web.BaseUrlAccessor.BaseUrlMutator, org.refcodes.web.BaseUrlAccessor.BaseUrlProperty, org.refcodes.web.BasicAuthCredentialsAccessor, org.refcodes.web.BasicAuthCredentialsAccessor.BasicAuthCredentialsBuilder<RestClient>, org.refcodes.web.BasicAuthCredentialsAccessor.BasicAuthCredentialsMutator, org.refcodes.web.BasicAuthCredentialsAccessor.BasicAuthCredentialsProperty, org.refcodes.web.LoadBalancingStrategyAccessor, org.refcodes.web.LoadBalancingStrategyAccessor.LoadBalancingStrategyBuilder<B>, org.refcodes.web.LoadBalancingStrategyAccessor.LoadBalancingStrategyMutator, org.refcodes.web.LoadBalancingStrategyAccessor.LoadBalancingStrategyProperty, org.refcodes.web.MediaTypeFactoryLookup, org.refcodes.web.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup, org.refcodes.web.OauthTokenAccessor, org.refcodes.web.OauthTokenAccessor.OauthTokenBuilder<RestClient>, org.refcodes.web.OauthTokenAccessor.OauthTokenMutator, org.refcodes.web.OauthTokenAccessor.OauthTokenProperty, org.refcodes.web.UserAgentAccessor, org.refcodes.web.UserAgentAccessor.UserAgentBuilder<RestClient>, org.refcodes.web.UserAgentAccessor.UserAgentMutator, org.refcodes.web.UserAgentAccessor.UserAgentProperty

public abstract class AbstractHttpDiscoveryRestClientDecorator<B extends HttpDiscoveryRestClient<B>> extends AbstractHttpRestClientDecorator<B> implements HttpDiscoveryRestClient<B>
Abstract class for easily decorating a HttpDiscoveryRestClient.
  • Field Details

    • _lifeCycleAutomaton

      protected org.refcodes.component.LifecycleAutomatonImpl.ManualLifecycleAutomatonImpl _lifeCycleAutomaton
  • Constructor Details

    • AbstractHttpDiscoveryRestClientDecorator

      public AbstractHttpDiscoveryRestClientDecorator(HttpRestClient aClient)
      Decorates the given HttpRestClient with discovery functionality.
      Parameters:
      aClient - The HttpRestClient to be decorated.
  • Method Details

    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface org.refcodes.component.RunningAccessor
    • isInitialized

      public boolean isInitialized()
      Specified by:
      isInitialized in interface org.refcodes.component.InitializedAccessor
    • getLifecycleStatus

      public org.refcodes.component.LifecycleStatus getLifecycleStatus()
      Specified by:
      getLifecycleStatus in interface org.refcodes.component.LifecycleStatusAccessor
    • pause

      public void pause() throws org.refcodes.component.PauseException
      Pauses the resolving of the host part of an Url from the list of available services and their accordingly associated Url as of the discovery service.
      Specified by:
      pause in interface HttpDiscovery<B extends HttpDiscoveryRestClient<B>>
      Specified by:
      pause in interface org.refcodes.component.Pausable
      Throws:
      org.refcodes.component.PauseException
    • stop

      public void stop() throws org.refcodes.component.StopException
      Stops resolving of the host part of an Url from the list of available services and their accordingly associated Url as of the discovery service. Does not update the list of available services and their accordingly associated Url from the discovery service. This may be achieved by canceling a scheduler.
      Specified by:
      stop in interface HttpDiscovery<B extends HttpDiscoveryRestClient<B>>
      Specified by:
      stop in interface org.refcodes.component.Stoppable
      Throws:
      org.refcodes.component.StopException
    • start

      public void start() throws org.refcodes.component.StartException
      Starts resolving of the host part of an Url from the list of available services and their accordingly associated Url as of the discovery service. Takes care to update the list of available services and their accordingly associated Url from the discovery service. This may be achieved by starting a scheduler. If necessary, the connection is opened.
      Specified by:
      start in interface HttpDiscovery<B extends HttpDiscoveryRestClient<B>>
      Specified by:
      start in interface org.refcodes.component.Startable
      Throws:
      org.refcodes.component.StartException
    • resume

      public void resume() throws org.refcodes.component.ResumeException
      Resumes the resolving of the host part of an Url from the list of available services and their accordingly associated Url as of the discovery service.
      Specified by:
      resume in interface HttpDiscovery<B extends HttpDiscoveryRestClient<B>>
      Specified by:
      resume in interface org.refcodes.component.Resumable
      Throws:
      org.refcodes.component.ResumeException
    • initialize

      public void initialize() throws org.refcodes.component.InitializeException
      Initially fetches the list of available services and their accordingly associated Url from the discovery service. Sets up the client according to the current client's state when invoking HttpDiscovery.initialize(Url, LoadBalancingStrategy, TrustStoreDescriptor).
      Specified by:
      initialize in interface HttpDiscovery<B extends HttpDiscoveryRestClient<B>>
      Specified by:
      initialize in interface org.refcodes.component.Initializable
      Throws:
      org.refcodes.component.InitializeException
    • isStoppable

      public boolean isStoppable()
      Specified by:
      isStoppable in interface org.refcodes.component.Stoppable.StopAutomaton
    • isPausable

      public boolean isPausable()
      Specified by:
      isPausable in interface org.refcodes.component.Pausable.PauseAutomaton
    • isStartable

      public boolean isStartable()
      Specified by:
      isStartable in interface org.refcodes.component.Startable.StartAutomaton
    • isResumable

      public boolean isResumable()
      Specified by:
      isResumable in interface org.refcodes.component.Resumable.ResumeAutomaton
    • isStopped

      public boolean isStopped()
      Specified by:
      isStopped in interface org.refcodes.component.Stoppable.StopAutomaton
    • isPaused

      public boolean isPaused()
      Specified by:
      isPaused in interface org.refcodes.component.Pausable.PauseAutomaton
    • isInitalizable

      public boolean isInitalizable()
      Specified by:
      isInitalizable in interface org.refcodes.component.Initializable.InitializeAutomaton
    • destroy

      public void destroy()
      Stops resolving of the host part of an Url from the list of available services and their accordingly associated Url as of the discovery service. Does not update the list of available services and their accordingly associated Url from the discovery service. This may be achieved by canceling a scheduler. Finally the connection is closed.
      Specified by:
      destroy in interface org.refcodes.component.Destroyable
      Specified by:
      destroy in interface HttpDiscovery<B extends HttpDiscoveryRestClient<B>>
    • isDestroyable

      public boolean isDestroyable()
      Specified by:
      isDestroyable in interface org.refcodes.component.Destroyable.DestroyAutomaton
    • isDestroyed

      public boolean isDestroyed()
      Specified by:
      isDestroyed in interface org.refcodes.component.Destroyable.DestroyAutomaton
    • toUrl

      public abstract org.refcodes.web.Url toUrl(org.refcodes.web.Url aUrl)
      Hook for sub-classes to modify the request URL.
      Specified by:
      toUrl in interface HttpDiscovery<B extends HttpDiscoveryRestClient<B>>
      Overrides:
      toUrl in class AbstractHttpRestClientDecorator<B extends HttpDiscoveryRestClient<B>>
      Parameters:
      aUrl - The Url for the request.
      Returns:
      The tinkered Url, by default it returns the provided Url unmodified.
    • setLoadBalancingStrategy

      public void setLoadBalancingStrategy(org.refcodes.web.LoadBalancingStrategy aStrategy)
      Specified by:
      setLoadBalancingStrategy in interface org.refcodes.web.LoadBalancingStrategyAccessor.LoadBalancingStrategyMutator
    • getLoadBalancingStrategy

      public org.refcodes.web.LoadBalancingStrategy getLoadBalancingStrategy()
      Specified by:
      getLoadBalancingStrategy in interface org.refcodes.web.LoadBalancingStrategyAccessor
    • getHttpDiscoveryUrl

      public org.refcodes.web.Url getHttpDiscoveryUrl()
      Retrieves the URL from the URL property locating the service discovery discovery.
      Specified by:
      getHttpDiscoveryUrl in interface HttpDiscoveryUrlAccessor
      Returns:
      The URL stored by the URL property.
    • setHttpDiscoveryUrl

      public void setHttpDiscoveryUrl(org.refcodes.web.Url aUrl)
      Sets the URL for the URL property locating the service discovery discovery.
      Specified by:
      setHttpDiscoveryUrl in interface HttpDiscoveryUrlAccessor.HttpDiscoveryUrlMutator
      Parameters:
      aUrl - The service discovery discovery URL to be stored by the URL property.
    • toTrustStoreDescriptor

      protected org.refcodes.security.TrustStoreDescriptor toTrustStoreDescriptor(org.refcodes.security.TrustStoreDescriptor aStoreDescriptor)
    • toHttpDiscoveryUrl

      protected org.refcodes.web.Url toHttpDiscoveryUrl(org.refcodes.web.Url aDiscoveryUrl)
    • toLoadBalancerStrategy

      protected org.refcodes.web.LoadBalancingStrategy toLoadBalancerStrategy(org.refcodes.web.LoadBalancingStrategy aStrategy)