Class BasicAuthEndpointBuilder
java.lang.Object
org.refcodes.rest.BasicAuthEndpointBuilder
- All Implemented Interfaces:
Closable, Closable.CloseBuilder<LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>>, ConnectionStatusAccessor, LinkComponent, LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>, Openable, Openable.OpenBuilder<LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>>, OpenedAccessor, BasicAuthEndpoint, BasicAuthObserver, HttpMethodAccessor, HttpMethodAccessor.HttpMethodBuilder<BasicAuthEndpointBuilder>, HttpMethodAccessor.HttpMethodMutator, HttpMethodAccessor.HttpMethodProperty
public class BasicAuthEndpointBuilder
extends Object
implements BasicAuthEndpoint, HttpMethodAccessor.HttpMethodProperty, HttpMethodAccessor.HttpMethodBuilder<BasicAuthEndpointBuilder>, LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>, ConnectionStatusAccessor
A
BasicAuthEndpointBuilder extends an BasicAuthEndpoint with
builder functionality and adds lambda support for handling the
requests addressed to this BasicAuthEndpoint. The lambda
defined as BasicAuthObserver acts as the single listener to this
BasicAuthEndpoint responsible for handling the requests for which
this BasicAuthEndpoint is responsible. The locator for which an
BasicAuthEndpointBuilder is responsible for is defined by the
BasicAuthEndpointBuilder's Locator-Pattern: 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 method RestRequestEvent.getWildcardReplacements() . 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}".-
Nested Class Summary
Nested classes/interfaces inherited from interface Closable
Closable.CloseAutomaton, Closable.CloseBuilder<B>Nested classes/interfaces inherited from interface ConnectionStatusAccessor
ConnectionStatusAccessor.ConnectionStatusMutator, ConnectionStatusAccessor.ConnectionStatusPropertyNested classes/interfaces inherited from interface HttpMethodAccessor
HttpMethodAccessor.HttpMethodBuilder<B>, HttpMethodAccessor.HttpMethodMutator, HttpMethodAccessor.HttpMethodPropertyNested classes/interfaces inherited from interface LinkComponent
LinkComponent.LinkAutomaton, LinkComponent.LinkComponentBuilder<B>Nested classes/interfaces inherited from interface Openable
Openable.OpenAutomaton, Openable.OpenBuilder<B>Nested classes/interfaces inherited from interface OpenedAccessor
OpenedAccessor.OpenedMutator, OpenedAccessor.OpenedProperty -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConnectionStatusprotected HttpMethodprotected Stringprotected BasicAuthObserver -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a plainBasicAuthEndpointBuilder, make sure to provide the least required attributes as demonstrated by the constructorBasicAuthEndpointBuilder(HttpMethod, String, BasicAuthObserver).BasicAuthEndpointBuilder(HttpMethod aHttpMethod, String aLocatorPathPattern, BasicAuthObserver aRequestConsumer) Constructs anBasicAuthEndpointBuilderwith the least required attributes. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Retrieves the resource Locator-Pattern this endpoint has been registered to.Retrieves theBasicAuthObserverto which any requests are delegated upon invocation of theonBasicAuthRequest(java.net.InetSocketAddress, java.net.InetSocketAddress, HttpMethod, String, org.refcodes.web.BasicAuthCredentials, String)method.onBasicAuthRequest(InetSocketAddress aLocalAddress, InetSocketAddress aRemoteAddress, HttpMethod aHttpMethod, String aLocator, BasicAuthCredentials aCredentials, String aRealm) voidopen()voidsetHttpMethod(HttpMethod aHttpMethod) voidsetLocatorPathPattern(String aLocatorPathPattern) Sets the resource locator.voidsetRequestObserver(BasicAuthObserver aLambda) Sets theBasicAuthObserverto which any requests are delegated upon invocation of theonBasicAuthRequest(java.net.InetSocketAddress, java.net.InetSocketAddress, HttpMethod, String, org.refcodes.web.BasicAuthCredentials, String)method.withCloseIn(int aCloseMillis) withHttpMethod(HttpMethod aHttpMethod) withLocatorPathPattern(String aLocatorPathPattern) Sets the resource locator as of the Builder-Pattern.withOpen()withRequestObserver(BasicAuthObserver aLambda) Builder method for setting theBasicAuthObserver.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Closable
closeIn, closeQuietly, closeUncheckedMethods inherited from interface Closable.CloseBuilder
withCloseUncheckedMethods inherited from interface ConnectionStatusAccessor
isOpenedMethods inherited from interface HttpMethodAccessor.HttpMethodProperty
letHttpMethodMethods inherited from interface Openable
openUncheckedMethods inherited from interface Openable.OpenBuilder
withOpenUnchecked
-
Field Details
-
_requestObserver
-
_httpMethod
-
_locatorPattern
-
_connectionStatus
-
-
Constructor Details
-
BasicAuthEndpointBuilder
public BasicAuthEndpointBuilder()Constructs a plainBasicAuthEndpointBuilder, make sure to provide the least required attributes as demonstrated by the constructorBasicAuthEndpointBuilder(HttpMethod, String, BasicAuthObserver). -
BasicAuthEndpointBuilder
public BasicAuthEndpointBuilder(HttpMethod aHttpMethod, String aLocatorPathPattern, BasicAuthObserver aRequestConsumer) Constructs anBasicAuthEndpointBuilderwith the least required attributes.- Parameters:
aHttpMethod- The HTTP-Method to which thisBasicAuthEndpointBuilderis bound.aLocatorPathPattern- The local host's locator patter to which thisBasicAuthEndpointBuilderis bound. SeesetLocatorPathPattern(String)on the syntax of the pattern.aRequestConsumer- The listener processing requests targeted at thisBasicAuthEndpointBuilder.
-
-
Method Details
-
withHttpMethod
- Specified by:
withHttpMethodin interfaceHttpMethodAccessor.HttpMethodBuilder<BasicAuthEndpointBuilder>
-
withLocatorPathPattern
Sets the resource locator as of the Builder-Pattern. 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 methodRestRequestEvent.getWildcardReplacement(String). For ease of use, a named wildcard with single asterisk ("*") such as "${arg1}=*" can be abbreviated as "${arg1}".- Parameters:
aLocatorPathPattern- the locator pattern- Returns:
- The
BasicAuthEndpointbuilder to continue configuration (as of the Builder-Pattern).
-
withRequestObserver
Builder method for setting theBasicAuthObserver.- Parameters:
aLambda- The (user defined)BasicAuthObserverto handle requests, feel free to code it aslambdaexpression- Returns:
- The
BasicAuthEndpointBuilderfor the sake of a fluent API.
-
withOpen
- Specified by:
withOpenin interfaceOpenable.OpenBuilder<LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>>- Throws:
IOException
-
withClose
- Specified by:
withClosein interfaceClosable.CloseBuilder<LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>>- Throws:
IOException
-
withCloseQuietly
- Specified by:
withCloseQuietlyin interfaceClosable.CloseBuilder<LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>>
-
withCloseIn
- Specified by:
withCloseInin interfaceClosable.CloseBuilder<LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>>
-
setLocatorPathPattern
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 methodRestRequestEvent.getWildcardReplacement(String). For ease of use, a named wildcard with single asterisk ("*") such as "${arg1}=*" can be abbreviated as "${arg1}".- Parameters:
aLocatorPathPattern- the new locator pattern
-
setHttpMethod
- Specified by:
setHttpMethodin interfaceHttpMethodAccessor.HttpMethodMutator
-
setRequestObserver
Sets theBasicAuthObserverto which any requests are delegated upon invocation of theonBasicAuthRequest(java.net.InetSocketAddress, java.net.InetSocketAddress, HttpMethod, String, org.refcodes.web.BasicAuthCredentials, String)method.- Parameters:
aLambda- The (user defined)BasicAuthObserverto handle requests, feel free to code it aslambdaexpression!
-
getRequestObserver
Retrieves theBasicAuthObserverto which any requests are delegated upon invocation of theonBasicAuthRequest(java.net.InetSocketAddress, java.net.InetSocketAddress, HttpMethod, String, org.refcodes.web.BasicAuthCredentials, String)method.- Returns:
- The (user defined)
BasicAuthObserverto handle requests.
-
onBasicAuthRequest
public BasicAuthResponse onBasicAuthRequest(InetSocketAddress aLocalAddress, InetSocketAddress aRemoteAddress, HttpMethod aHttpMethod, String aLocator, BasicAuthCredentials aCredentials, String aRealm) - Specified by:
onBasicAuthRequestin interfaceBasicAuthObserver
-
getHttpMethod
- Specified by:
getHttpMethodin interfaceHttpMethodAccessor
-
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 theRestRequestEvent's methodRestRequestEvent.getWildcardReplacements()inside theBasicAuthObserver.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}?". TheRestRequestEventlets you access the wildcard substitutes either by index or by name.- Specified by:
getLocatorPathPatternin interfaceBasicAuthEndpoint- Returns:
- the locator path pattern
-
open
- Specified by:
openin interfaceOpenable- Throws:
IOException
-
close
- Specified by:
closein interfaceClosable- Throws:
IOException
-
getConnectionStatus
- Specified by:
getConnectionStatusin interfaceConnectionStatusAccessor
-