- java.lang.Object
-
- org.refcodes.rest.BasicAuthEndpointBuilder
-
- 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,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 BasicAuthEndpointBuilder extends Object implements BasicAuthEndpoint, org.refcodes.web.HttpMethodAccessor.HttpMethodProperty, org.refcodes.web.HttpMethodAccessor.HttpMethodBuilder<BasicAuthEndpointBuilder>, org.refcodes.component.LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>, org.refcodes.component.ConnectionStatusAccessor
ABasicAuthEndpointBuilderextends anBasicAuthEndpointwith builder functionality and addslambdasupport for handling the requests addressed to thisBasicAuthEndpoint. Thelambdadefined asBasicAuthObserveracts as the single listener to thisBasicAuthEndpointresponsible for handling the requests for which thisBasicAuthEndpointis responsible. The locator for which anBasicAuthEndpointBuilderis responsible for is defined by theBasicAuthEndpointBuilder'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 methodRestRequestEvent.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 methodRestRequestEvent.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 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>>
-
-
Field Summary
Fields Modifier and Type Field Description protected org.refcodes.component.ConnectionStatus_connectionStatusprotected org.refcodes.web.HttpMethod_httpMethodprotected String_locatorPatternprotected org.refcodes.web.BasicAuthObserver_requestObserver
-
Constructor Summary
Constructors Constructor Description BasicAuthEndpointBuilder()Constructs a plainBasicAuthEndpointBuilder, make sure to provide the least required attributes as demonstrated by the constructorBasicAuthEndpointBuilder(HttpMethod, String, BasicAuthObserver).BasicAuthEndpointBuilder(org.refcodes.web.HttpMethod aHttpMethod, String aLocatorPathPattern, org.refcodes.web.BasicAuthObserver aRequestConsumer)Constructs anBasicAuthEndpointBuilderwith the least required attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()org.refcodes.component.ConnectionStatusgetConnectionStatus()org.refcodes.web.HttpMethodgetHttpMethod()StringgetLocatorPathPattern()Retrieves the resource Locator-Pattern this endpoint has been registered to.org.refcodes.web.BasicAuthObservergetRequestObserver()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.org.refcodes.web.BasicAuthResponseonBasicAuthRequest(InetSocketAddress aLocalAddress, InetSocketAddress aRemoteAddress, org.refcodes.web.HttpMethod aHttpMethod, String aLocator, org.refcodes.web.BasicAuthCredentials aCredentials, String aRealm)voidopen()voidsetHttpMethod(org.refcodes.web.HttpMethod aHttpMethod)voidsetLocatorPathPattern(String aLocatorPathPattern)Sets the resource locator.voidsetRequestObserver(org.refcodes.web.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.BasicAuthEndpointBuilderwithClose()BasicAuthEndpointBuilderwithCloseIn(int aCloseInMillis)BasicAuthEndpointBuilderwithCloseQuietly()BasicAuthEndpointBuilderwithHttpMethod(org.refcodes.web.HttpMethod aHttpMethod)BasicAuthEndpointBuilderwithLocatorPathPattern(String aLocatorPathPattern)Sets the resource locator as of the Builder-Pattern.BasicAuthEndpointBuilderwithOpen()BasicAuthEndpointBuilderwithRequestObserver(org.refcodes.web.BasicAuthObserver aLambda)Builder method for setting theBasicAuthObserver.-
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
-
-
-
-
Field Detail
-
_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 Detail
-
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(org.refcodes.web.HttpMethod aHttpMethod, String aLocatorPathPattern, org.refcodes.web.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 Detail
-
withHttpMethod
public BasicAuthEndpointBuilder withHttpMethod(org.refcodes.web.HttpMethod aHttpMethod)
- Specified by:
withHttpMethodin interfaceorg.refcodes.web.HttpMethodAccessor.HttpMethodBuilder<BasicAuthEndpointBuilder>
-
withLocatorPathPattern
public BasicAuthEndpointBuilder withLocatorPathPattern(String aLocatorPathPattern)
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
public BasicAuthEndpointBuilder withRequestObserver(org.refcodes.web.BasicAuthObserver aLambda)
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
public BasicAuthEndpointBuilder withOpen() throws IOException
- Specified by:
withOpenin interfaceorg.refcodes.component.Openable.OpenBuilder<org.refcodes.component.LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>>- Throws:
IOException
-
withClose
public BasicAuthEndpointBuilder withClose() throws IOException
- Specified by:
withClosein interfaceorg.refcodes.component.Closable.CloseBuilder<org.refcodes.component.LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>>- Throws:
IOException
-
withCloseQuietly
public BasicAuthEndpointBuilder withCloseQuietly()
- Specified by:
withCloseQuietlyin interfaceorg.refcodes.component.Closable.CloseBuilder<org.refcodes.component.LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>>
-
withCloseIn
public BasicAuthEndpointBuilder withCloseIn(int aCloseInMillis)
- Specified by:
withCloseInin interfaceorg.refcodes.component.Closable.CloseBuilder<org.refcodes.component.LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>>
-
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 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
public void setHttpMethod(org.refcodes.web.HttpMethod aHttpMethod)
- Specified by:
setHttpMethodin interfaceorg.refcodes.web.HttpMethodAccessor.HttpMethodMutator
-
setRequestObserver
public void setRequestObserver(org.refcodes.web.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.- Parameters:
aLambda- The (user defined)BasicAuthObserverto handle requests, feel free to code it aslambdaexpression!
-
getRequestObserver
public org.refcodes.web.BasicAuthObserver 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 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:
onBasicAuthRequestin interfaceorg.refcodes.web.BasicAuthObserver
-
getHttpMethod
public org.refcodes.web.HttpMethod getHttpMethod()
- Specified by:
getHttpMethodin interfaceorg.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 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
-
open
public void open() throws IOException- Specified by:
openin interfaceorg.refcodes.component.Openable- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceorg.refcodes.component.Closable- Throws:
IOException
-
getConnectionStatus
public org.refcodes.component.ConnectionStatus getConnectionStatus()
- Specified by:
getConnectionStatusin interfaceorg.refcodes.component.ConnectionStatusAccessor
-
-