Class BasicAuthEndpointBuilderImpl

java.lang.Object
org.refcodes.rest.BasicAuthEndpointBuilderImpl
All Implemented Interfaces:
org.refcodes.component.Closable, org.refcodes.component.Closable.CloseBuilder<org.refcodes.component.LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>>, org.refcodes.component.ConnectionStatusAccessor, org.refcodes.component.LinkComponent, org.refcodes.component.LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>, org.refcodes.component.Openable, org.refcodes.component.Openable.OpenBuilder<org.refcodes.component.LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>>, org.refcodes.component.OpenedAccessor, BasicAuthEndpoint, BasicAuthEndpointBuilder, org.refcodes.web.BasicAuthObserver, org.refcodes.web.HttpMethodAccessor, org.refcodes.web.HttpMethodAccessor.HttpMethodBuilder<BasicAuthEndpointBuilder>, org.refcodes.web.HttpMethodAccessor.HttpMethodMutator, org.refcodes.web.HttpMethodAccessor.HttpMethodProperty

public class BasicAuthEndpointBuilderImpl
extends Object
implements BasicAuthEndpointBuilder
The implementation of the BasicAuthEndpointBuilder interface as good old POJO for use by different RestServer implementations.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.refcodes.component.Closable

    org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.Closable.CloseBuilder<B extends org.refcodes.component.Closable.CloseBuilder<B>>

    Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionStatusAccessor

    org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusMutator, org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusProperty

    Nested classes/interfaces inherited from interface org.refcodes.web.HttpMethodAccessor

    org.refcodes.web.HttpMethodAccessor.HttpMethodBuilder<B extends org.refcodes.web.HttpMethodAccessor.HttpMethodBuilder<B>>, org.refcodes.web.HttpMethodAccessor.HttpMethodMutator, org.refcodes.web.HttpMethodAccessor.HttpMethodProperty

    Nested classes/interfaces inherited from interface org.refcodes.component.LinkComponent

    org.refcodes.component.LinkComponent.LinkAutomaton, org.refcodes.component.LinkComponent.LinkComponentBuilder<B extends org.refcodes.component.LinkComponent.LinkComponentBuilder<B>>

    Nested classes/interfaces inherited from interface org.refcodes.component.Openable

    org.refcodes.component.Openable.OpenAutomaton, org.refcodes.component.Openable.OpenBuilder<B extends org.refcodes.component.Openable.OpenBuilder<B>>

    Nested classes/interfaces inherited from interface org.refcodes.component.OpenedAccessor

    org.refcodes.component.OpenedAccessor.OpenedMutator, org.refcodes.component.OpenedAccessor.OpenedProperty
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected org.refcodes.component.ConnectionStatus _connectionStatus  
    protected org.refcodes.web.HttpMethod _httpMethod  
    protected String _locatorPattern  
    protected org.refcodes.web.BasicAuthObserver _requestObserver  
  • Constructor Summary

    Constructors
    Constructor Description
    BasicAuthEndpointBuilderImpl()
    Constructs a plain BasicAuthEndpointBuilder, make sure to provide the least required attributes as demonstrated by the constructor BasicAuthEndpointBuilderImpl(HttpMethod, String, BasicAuthObserver).
    BasicAuthEndpointBuilderImpl​(org.refcodes.web.HttpMethod aHttpMethod, String aLocatorPathPattern, org.refcodes.web.BasicAuthObserver aRequestConsumer)
    Constructs an BasicAuthEndpointBuilder with the least required attributes.
  • Method Summary

    Modifier and Type Method Description
    void close()
    org.refcodes.component.ConnectionStatus getConnectionStatus()
    org.refcodes.web.HttpMethod getHttpMethod()
    String getLocatorPathPattern()
    Retrieves the resource Locator-Pattern this endpoint has been registered to.
    org.refcodes.web.BasicAuthObserver getRequestObserver()
    Retrieves the BasicAuthObserver to which any requests are delegated upon invocation of the BasicAuthObserver.onBasicAuthRequest(java.net.InetSocketAddress, java.net.InetSocketAddress, HttpMethod, String, org.refcodes.web.BasicAuthCredentials, String) method.
    org.refcodes.web.BasicAuthResponse onBasicAuthRequest​(InetSocketAddress aLocalAddress, InetSocketAddress aRemoteAddress, org.refcodes.web.HttpMethod aHttpMethod, String aLocator, org.refcodes.web.BasicAuthCredentials aCredentials, String aRealm)
    void open()
    void setHttpMethod​(org.refcodes.web.HttpMethod aHttpMethod)
    void setLocatorPathPattern​(String aLocatorPathPattern)
    Sets the resource locator.
    void setRequestObserver​(org.refcodes.web.BasicAuthObserver aLambda)
    Sets the BasicAuthObserver to which any requests are delegated upon invocation of the BasicAuthObserver.onBasicAuthRequest(java.net.InetSocketAddress, java.net.InetSocketAddress, HttpMethod, String, org.refcodes.web.BasicAuthCredentials, String) method.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.refcodes.component.Closable

    closeIn, closeQuietly, closeUnchecked

    Methods inherited from interface org.refcodes.component.Closable.CloseBuilder

    withCloseUnchecked

    Methods inherited from interface org.refcodes.component.ConnectionStatusAccessor

    isOpened

    Methods inherited from interface org.refcodes.web.HttpMethodAccessor.HttpMethodProperty

    letHttpMethod

    Methods inherited from interface org.refcodes.component.Openable

    openUnchecked

    Methods inherited from interface org.refcodes.component.Openable.OpenBuilder

    withOpenUnchecked
  • Field Details

    • _requestObserver

      protected org.refcodes.web.BasicAuthObserver _requestObserver
    • _httpMethod

      protected org.refcodes.web.HttpMethod _httpMethod
    • _locatorPattern

      protected String _locatorPattern
    • _connectionStatus

      protected org.refcodes.component.ConnectionStatus _connectionStatus
  • Constructor Details

  • Method Details

    • setLocatorPathPattern

      public void setLocatorPathPattern​(String aLocatorPathPattern)
      Sets the resource locator. The locator may contain wildcards as known from file-systems as follows: A single asterisk ("*") matches zero or more characters within a locator name. A double asterisk ("**") matches zero or more characters across directory levels. A question mark ("?") matches exactly one character within a locator name. You may name a wildcard by prefixing it with "${someWildcardName}". For example a named wildcard may look as follows: "${arg1}=*" or "${arg2}=**" or "${arg3}=?". You can get the text substituting a named wildcard using the method RestRequestEvent.getWildcardReplacement(String). For ease of use, a named wildcard with single asterisk ("*") such as "${arg1}=*" can be abbreviated as "${arg1}".
      Specified by:
      setLocatorPathPattern in interface BasicAuthEndpointBuilder
      Parameters:
      aLocatorPathPattern - the new locator pattern
    • setHttpMethod

      public void setHttpMethod​(org.refcodes.web.HttpMethod aHttpMethod)
      Specified by:
      setHttpMethod in interface org.refcodes.web.HttpMethodAccessor.HttpMethodMutator
    • setRequestObserver

      public void setRequestObserver​(org.refcodes.web.BasicAuthObserver aLambda)
      Sets the BasicAuthObserver to which any requests are delegated upon invocation of the BasicAuthObserver.onBasicAuthRequest(java.net.InetSocketAddress, java.net.InetSocketAddress, HttpMethod, String, org.refcodes.web.BasicAuthCredentials, String) method.
      Specified by:
      setRequestObserver in interface BasicAuthEndpointBuilder
      Parameters:
      aLambda - The (user defined) BasicAuthObserver to handle requests, feel free to code it as lambda expression!
    • getRequestObserver

      public org.refcodes.web.BasicAuthObserver getRequestObserver()
      Retrieves the BasicAuthObserver to which any requests are delegated upon invocation of the BasicAuthObserver.onBasicAuthRequest(java.net.InetSocketAddress, java.net.InetSocketAddress, HttpMethod, String, org.refcodes.web.BasicAuthCredentials, String) method.
      Specified by:
      getRequestObserver in interface BasicAuthEndpointBuilder
      Returns:
      The (user defined) BasicAuthObserver to handle requests.
    • onBasicAuthRequest

      public org.refcodes.web.BasicAuthResponse onBasicAuthRequest​(InetSocketAddress aLocalAddress, InetSocketAddress aRemoteAddress, org.refcodes.web.HttpMethod aHttpMethod, String aLocator, org.refcodes.web.BasicAuthCredentials aCredentials, String aRealm)
      Specified by:
      onBasicAuthRequest in interface org.refcodes.web.BasicAuthObserver
    • getHttpMethod

      public org.refcodes.web.HttpMethod getHttpMethod()
      Specified by:
      getHttpMethod in interface org.refcodes.web.HttpMethodAccessor
    • getLocatorPathPattern

      public String getLocatorPathPattern()
      Retrieves the resource Locator-Pattern this endpoint has been registered to. The Locator-Pattern may contain wildcards as known from file-systems as follows: A single asterisk ("*") matches zero or more characters within a locator name. A double asterisk ("**") matches zero or more characters across directory levels. A question mark ("?") matches exactly one character within a locator name. The single asterisk ("*"), the double asterisk ("**") and the question mark ("?") we refer to as wildcard: You get an array with the substitutes of the wildcards using the RestRequestEvent's method RestRequestEvent.getWildcardReplacements() inside the BasicAuthObserver.onBasicAuthRequest(java.net.InetSocketAddress, java.net.InetSocketAddress, HttpMethod, String, org.refcodes.web.BasicAuthCredentials, String) method. You may name a wildcard by prefixing it with "{someWildcardName}". For example a named wildcard may look as follows: "{arg1}*" or "{arg2}**" or "{arg3}?". The RestRequestEvent lets you access the wildcard substitutes either by index or by name.
      Specified by:
      getLocatorPathPattern in interface BasicAuthEndpoint
    • open

      public void open() throws IOException
      Specified by:
      open in interface org.refcodes.component.Openable
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface org.refcodes.component.Closable
      Throws:
      IOException
    • getConnectionStatus

      public org.refcodes.component.ConnectionStatus getConnectionStatus()
      Specified by:
      getConnectionStatus in interface org.refcodes.component.ConnectionStatusAccessor