Package org.refcodes.rest
Class BasicAuthEndpointBuilderImpl
- java.lang.Object
-
- org.refcodes.rest.BasicAuthEndpointBuilderImpl
-
- All Implemented Interfaces:
org.refcodes.component.Closable
,org.refcodes.component.Closable.CloseBuilder<BasicAuthEndpointBuilder>
,org.refcodes.component.ConnectionStatusAccessor
,org.refcodes.component.LinkComponent
,org.refcodes.component.LinkComponent.LinkComponentBuilder<BasicAuthEndpointBuilder>
,org.refcodes.component.Openable
,org.refcodes.component.Openable.OpenBuilder<BasicAuthEndpointBuilder>
,org.refcodes.net.BasicAuthObserver
,org.refcodes.net.HttpMethodAccessor
,org.refcodes.net.HttpMethodAccessor.HttpMethodBuilder<BasicAuthEndpointBuilder>
,org.refcodes.net.HttpMethodAccessor.HttpMethodMutator
,org.refcodes.net.HttpMethodAccessor.HttpMethodProperty
,BasicAuthEndpoint
,BasicAuthEndpointBuilder
public class BasicAuthEndpointBuilderImpl extends java.lang.Object implements BasicAuthEndpointBuilder
The implementation of theBasicAuthEndpointBuilder
interface as good old POJO for use by differentRestServer
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.net.HttpMethodAccessor
org.refcodes.net.HttpMethodAccessor.HttpMethodBuilder<B extends org.refcodes.net.HttpMethodAccessor.HttpMethodBuilder<B>>, org.refcodes.net.HttpMethodAccessor.HttpMethodMutator, org.refcodes.net.HttpMethodAccessor.HttpMethodProperty
-
-
Field Summary
Fields Modifier and Type Field Description protected org.refcodes.component.ConnectionStatus
_connectionStatus
protected org.refcodes.net.HttpMethod
_httpMethod
protected java.lang.String
_locatorPattern
protected org.refcodes.net.BasicAuthObserver
_requestObserver
-
Constructor Summary
Constructors Constructor Description BasicAuthEndpointBuilderImpl()
Constructs a plainBasicAuthEndpointBuilder
, make sure to provide the least required attributes as demonstrated by the constructorBasicAuthEndpointBuilderImpl(HttpMethod, String, BasicAuthObserver)
.BasicAuthEndpointBuilderImpl(org.refcodes.net.HttpMethod aHttpMethod, java.lang.String aLocatorPattern, org.refcodes.net.BasicAuthObserver aRequestObserver)
Constructs anBasicAuthEndpointBuilder
with the least required attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
org.refcodes.component.ConnectionStatus
getConnectionStatus()
org.refcodes.net.HttpMethod
getHttpMethod()
java.lang.String
getLocatorPattern()
Retrieves the resource Locator-Pattern this endpoint has been registered to.org.refcodes.net.BasicAuthObserver
getRequestObserver()
Retrieves theBasicAuthObserver
to which any requests are delegated upon invocation of theBasicAuthObserver.onBasicAuthRequest(java.net.InetSocketAddress, java.net.InetSocketAddress, HttpMethod, String, org.refcodes.net.BasicAuthCredentials, String)
method.org.refcodes.net.BasicAuthResponse
onBasicAuthRequest(java.net.InetSocketAddress aLocalAddress, java.net.InetSocketAddress aRemoteAddress, org.refcodes.net.HttpMethod aHttpMethod, java.lang.String aLocator, org.refcodes.net.BasicAuthCredentials aCredentials, java.lang.String aRealm)
void
open()
void
setHttpMethod(org.refcodes.net.HttpMethod aHttpMethod)
void
setLocatorPattern(java.lang.String aLocatorPattern)
Sets the resource locator.void
setRequestObserver(org.refcodes.net.BasicAuthObserver aLambda)
Sets theBasicAuthObserver
to which any requests are delegated upon invocation of theBasicAuthObserver.onBasicAuthRequest(java.net.InetSocketAddress, java.net.InetSocketAddress, HttpMethod, String, org.refcodes.net.BasicAuthCredentials, String)
method.-
Methods inherited from interface org.refcodes.rest.BasicAuthEndpointBuilder
withClose, withCloseIn, withCloseQuietly, withHttpMethod, withLocatorPattern, withOpen, withRequestObserver
-
Methods inherited from interface org.refcodes.component.Closable
closeIn, closeQuietly, closeUnchecked
-
-
-
-
Constructor Detail
-
BasicAuthEndpointBuilderImpl
public BasicAuthEndpointBuilderImpl()
Constructs a plainBasicAuthEndpointBuilder
, make sure to provide the least required attributes as demonstrated by the constructorBasicAuthEndpointBuilderImpl(HttpMethod, String, BasicAuthObserver)
.
-
BasicAuthEndpointBuilderImpl
public BasicAuthEndpointBuilderImpl(org.refcodes.net.HttpMethod aHttpMethod, java.lang.String aLocatorPattern, org.refcodes.net.BasicAuthObserver aRequestObserver)
Constructs anBasicAuthEndpointBuilder
with the least required attributes.- Parameters:
aHttpMethod
- The HTTP-Method to which thisBasicAuthEndpointBuilder
is bound.aLocatorPattern
- The local host's locator patter to which thisBasicAuthEndpointBuilder
is bound. SeesetLocatorPattern(String)
on the syntax of the pattern.aRequestObserver
- The listener processing requests targeted at thisBasicAuthEndpointBuilder
.
-
-
Method Detail
-
setLocatorPattern
public void setLocatorPattern(java.lang.String aLocatorPattern)
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 methodWildcardSubstitutes.getWildcardReplacement(String)
. For ease of use, a named wildcard with single asterisk ("*") such as "${arg1}=*" can be abbreviated as "${arg1}".- Specified by:
setLocatorPattern
in interfaceBasicAuthEndpointBuilder
- Parameters:
aLocatorPattern
- the new locator pattern
-
setHttpMethod
public void setHttpMethod(org.refcodes.net.HttpMethod aHttpMethod)
- Specified by:
setHttpMethod
in interfaceorg.refcodes.net.HttpMethodAccessor.HttpMethodMutator
-
setRequestObserver
public void setRequestObserver(org.refcodes.net.BasicAuthObserver aLambda)
Sets theBasicAuthObserver
to which any requests are delegated upon invocation of theBasicAuthObserver.onBasicAuthRequest(java.net.InetSocketAddress, java.net.InetSocketAddress, HttpMethod, String, org.refcodes.net.BasicAuthCredentials, String)
method.- Specified by:
setRequestObserver
in interfaceBasicAuthEndpointBuilder
- Parameters:
aLambda
- The (user defined)BasicAuthObserver
to handle requests, feel free to code it aslambda
expression!
-
getRequestObserver
public org.refcodes.net.BasicAuthObserver getRequestObserver()
Retrieves theBasicAuthObserver
to which any requests are delegated upon invocation of theBasicAuthObserver.onBasicAuthRequest(java.net.InetSocketAddress, java.net.InetSocketAddress, HttpMethod, String, org.refcodes.net.BasicAuthCredentials, String)
method.- Specified by:
getRequestObserver
in interfaceBasicAuthEndpointBuilder
- Returns:
- The (user defined)
BasicAuthObserver
to handle requests.
-
onBasicAuthRequest
public org.refcodes.net.BasicAuthResponse onBasicAuthRequest(java.net.InetSocketAddress aLocalAddress, java.net.InetSocketAddress aRemoteAddress, org.refcodes.net.HttpMethod aHttpMethod, java.lang.String aLocator, org.refcodes.net.BasicAuthCredentials aCredentials, java.lang.String aRealm)
- Specified by:
onBasicAuthRequest
in interfaceorg.refcodes.net.BasicAuthObserver
-
getHttpMethod
public org.refcodes.net.HttpMethod getHttpMethod()
- Specified by:
getHttpMethod
in interfaceorg.refcodes.net.HttpMethodAccessor
-
getLocatorPattern
public java.lang.String getLocatorPattern()
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 methodWildcardSubstitutes.getWildcardReplacements()
inside theBasicAuthObserver.onBasicAuthRequest(java.net.InetSocketAddress, java.net.InetSocketAddress, HttpMethod, String, org.refcodes.net.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}?". TheRestRequestEvent
lets you access the wildcard substitutes either by index or by name.- Specified by:
getLocatorPattern
in interfaceBasicAuthEndpoint
-
open
public void open() throws org.refcodes.component.OpenException
- Specified by:
open
in interfaceorg.refcodes.component.Openable
- Throws:
org.refcodes.component.OpenException
-
close
public void close() throws org.refcodes.component.CloseException
- Specified by:
close
in interfaceorg.refcodes.component.Closable
- Throws:
org.refcodes.component.CloseException
-
getConnectionStatus
public org.refcodes.component.ConnectionStatus getConnectionStatus()
- Specified by:
getConnectionStatus
in interfaceorg.refcodes.component.ConnectionStatusAccessor
-
-