Class AbstractHttpRestServerDecorator<B extends HttpRestServer>

  • All Implemented Interfaces:
    org.refcodes.component.Closable, org.refcodes.component.Closable.CloseBuilder<B>, org.refcodes.component.ConnectionComponent<B>, org.refcodes.component.ConnectionComponent.ConnectionComponentBuilder<org.refcodes.net.HttpServerContext,HttpRestServer>, org.refcodes.component.ConnectionOpenable<B>, org.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<RestEndpoint,RestServer>, org.refcodes.component.ConnectionStatusAccessor, org.refcodes.component.LinkComponent, org.refcodes.component.Openable, org.refcodes.io.MaxConnectionsAccessor, org.refcodes.io.MaxConnectionsAccessor.MaxConnectionsBuilder<B>, org.refcodes.io.MaxConnectionsAccessor.MaxConnectionsMutator, org.refcodes.io.MaxConnectionsAccessor.MaxConnectionsProperty, org.refcodes.mixin.PortAccessor, org.refcodes.mixin.PortAccessor.PortBuilder<B>, org.refcodes.mixin.PortAccessor.PortMutator, org.refcodes.mixin.PortAccessor.PortProperty, org.refcodes.net.BaseLocatorAccessor, org.refcodes.net.BaseLocatorAccessor.BaseLocatorBuilder<B>, org.refcodes.net.BaseLocatorAccessor.BaseLocatorMutator, org.refcodes.net.BaseLocatorAccessor.BaseLocatorProperty, org.refcodes.net.BasicAuthObservable<B>, org.refcodes.net.HttpsConnectionRequestObservable<B>, org.refcodes.net.MediaTypeFactoryLookup, org.refcodes.net.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup, org.refcodes.net.RealmAccessor, org.refcodes.net.RealmAccessor.RealmBuilder<B>, org.refcodes.net.RealmAccessor.RealmMutator, org.refcodes.net.RealmAccessor.RealmProperty, org.refcodes.net.SchemeAccessor, org.refcodes.net.SchemeAccessor.SchemeBuilder<B>, org.refcodes.net.SchemeAccessor.SchemeMutator, org.refcodes.net.SchemeAccessor.SchemeProperty, org.refcodes.observer.Observable<B>, org.refcodes.observer.Observers<RestEndpoint,RestServer>, HttpExceptionHandlerAccessor, HttpExceptionHandlerAccessor.HttpExceptionHandlerBuilder<B>, HttpExceptionHandlerAccessor.HttpExceptionHandlerMutator, HttpExceptionHandlerAccessor.HttpExceptionHandlerProperty, HttpExceptionHandlingAccessor, HttpExceptionHandlingAccessor.HttpExceptionHandlingBuilder<B>, HttpExceptionHandlingAccessor.HttpExceptionHandlingMutator, HttpExceptionHandlingAccessor.HttpExceptionHandlingProperty, HttpRestServer, RestServer, org.refcodes.runtime.RequestCorrelation<B>, org.refcodes.runtime.SessionCorrelation<B>, org.refcodes.security.KeyStoreDescriptorAccessor, org.refcodes.security.KeyStoreDescriptorAccessor.KeyStoreDescriptorBuilder<B>, org.refcodes.security.KeyStoreDescriptorAccessor.KeyStoreDescriptorMutator, org.refcodes.security.KeyStoreDescriptorAccessor.KeyStoreDescriptorProperty
    Direct Known Subclasses:
    AbstractHttpRegistryRestServerDecorator


    public abstract class AbstractHttpRestServerDecorator<B extends HttpRestServer>
    extends java.lang.Object
    implements HttpRestServer
    Abstract class for easily decorating a HttpRestServer.
    • Constructor Detail

      • AbstractHttpRestServerDecorator

        public AbstractHttpRestServerDecorator​(HttpRestServer aServer)
        Decorates the given HttpRestServer with additional functionality.
        Parameters:
        aServer - The HttpRestServer to be decorated.
    • Method Detail

      • getPort

        public int getPort​()
        Specified by:
        getPort in interface org.refcodes.mixin.PortAccessor
      • setPort

        public void setPort​(int aPort)
        Specified by:
        setPort in interface org.refcodes.mixin.PortAccessor.PortMutator
      • getScheme

        public org.refcodes.data.Scheme getScheme​()
        Specified by:
        getScheme in interface org.refcodes.net.SchemeAccessor
      • setScheme

        public void setScheme​(org.refcodes.data.Scheme aScheme)
        Specified by:
        setScheme in interface org.refcodes.net.SchemeAccessor.SchemeMutator
      • addMediaTypeFactory

        public boolean addMediaTypeFactory​(org.refcodes.net.MediaTypeFactory aMediaTypeFactory)
        Specified by:
        addMediaTypeFactory in interface org.refcodes.net.MediaTypeFactoryLookup.MutableMediaTypeFactoryLookup
      • close

        public void close​()
                   throws org.refcodes.component.CloseException
        Specified by:
        close in interface org.refcodes.component.Closable
        Throws:
        org.refcodes.component.CloseException
      • closeIn

        public void closeIn​(int aCloseInMillis)
        Specified by:
        closeIn in interface org.refcodes.component.Closable
      • closeQuietly

        public void closeQuietly​()
        Specified by:
        closeQuietly in interface org.refcodes.component.Closable
      • closeUnchecked

        public void closeUnchecked​()
        Specified by:
        closeUnchecked in interface org.refcodes.component.Closable
      • disableRequestCorrelation

        public void disableRequestCorrelation​()
        Specified by:
        disableRequestCorrelation in interface org.refcodes.runtime.RequestCorrelation<B extends HttpRestServer>
      • disableSessionCorrelation

        public void disableSessionCorrelation​()
        Specified by:
        disableSessionCorrelation in interface org.refcodes.runtime.SessionCorrelation<B extends HttpRestServer>
      • enableRequestCorrelation

        public void enableRequestCorrelation​()
        Specified by:
        enableRequestCorrelation in interface org.refcodes.runtime.RequestCorrelation<B extends HttpRestServer>
      • enableSessionCorrelation

        public void enableSessionCorrelation​()
        Specified by:
        enableSessionCorrelation in interface org.refcodes.runtime.SessionCorrelation<B extends HttpRestServer>
      • getBaseLocator

        public java.lang.String getBaseLocator​()
        Specified by:
        getBaseLocator in interface org.refcodes.net.BaseLocatorAccessor
      • getFactoryMediaTypes

        public org.refcodes.net.MediaType[] getFactoryMediaTypes​()
        Specified by:
        getFactoryMediaTypes in interface org.refcodes.net.MediaTypeFactoryLookup
      • getRealm

        public java.lang.String getRealm​()
        Specified by:
        getRealm in interface org.refcodes.net.RealmAccessor
      • hasMediaTypeFactory

        public boolean hasMediaTypeFactory​(org.refcodes.net.MediaType aMediaType)
        Specified by:
        hasMediaTypeFactory in interface org.refcodes.net.MediaTypeFactoryLookup
      • hasObserverSubscription

        public boolean hasObserverSubscription​(RestEndpoint aObserver)
        Specified by:
        hasObserverSubscription in interface org.refcodes.observer.Observable<B extends HttpRestServer>
      • hasRequestCorrelation

        public boolean hasRequestCorrelation​()
        Specified by:
        hasRequestCorrelation in interface org.refcodes.runtime.RequestCorrelation<B extends HttpRestServer>
      • hasSessionCorrelation

        public boolean hasSessionCorrelation​()
        Specified by:
        hasSessionCorrelation in interface org.refcodes.runtime.SessionCorrelation<B extends HttpRestServer>
      • onBasicAuthRequest

        public B onBasicAuthRequest​(org.refcodes.net.BasicAuthObserver aObserver)
        Specified by:
        onBasicAuthRequest in interface org.refcodes.net.BasicAuthObservable<B extends HttpRestServer>
      • onConnectionRequest

        public B onConnectionRequest​(org.refcodes.net.HttpsConnectionRequestObserver aObserver)
        Specified by:
        onConnectionRequest in interface org.refcodes.net.HttpsConnectionRequestObservable<B extends HttpRestServer>
      • onRequest

        public RestEndpointBuilder onRequest​(org.refcodes.net.HttpMethod aHttpMethod,
                                             java.lang.String aLocatorPathPattern,
                                             RestRequestObserver aRequestObserver)
        Registers a pre-configured RestEndpoint with the least required attributes and returns its instance. To unsubscribe via Observable.unsubscribeObserver(Object), use the returned instance. Attention: Invoke Openable.open() to activate this endpoint!
        Specified by:
        onRequest in interface RestServer
        Parameters:
        aHttpMethod - The HTTP-Method to which this RestEndpoint is bound. A value of null means that any HTTP-Method may trigger this RestEndpoint.
        aLocatorPathPattern - The local Locator-Pattern to which this RestEndpoint is bound. A value of null means that any locator may trigger this RestEndpoint.
        aRequestObserver - The listener processing a request targeted at this RestEndpoint.
        Returns:
        The pre-configured RestEndpoint which acts as handle to unsubscribe the RestEndpoint via Observable.unsubscribeObserver(Object).
      • onRequest

        public RestEndpointBuilder onRequest​(java.lang.String aLocatorPathPattern,
                                             RestRequestObserver aRequestObserver)
        Registers a pre-configured RestEndpoint, triggerd by any HTTP method, and returns its instance. To unsubscribe via Observable.unsubscribeObserver(Object), use the returned instance. Attention: Invoke Openable.open() to activate this endpoint!
        Specified by:
        onRequest in interface RestServer
        Parameters:
        aLocatorPathPattern - The local locator (regular expression) pattern to which this RestEndpoint is bound.
        aRequestObserver - The listener processing a request targeted at this RestEndpoint.
        Returns:
        The pre-configured RestEndpoint which acts as handle to unsubscribe the RestEndpoint via Observable.unsubscribeObserver(Object).
      • onRequest

        public RestEndpointBuilder onRequest​(org.refcodes.net.HttpMethod aHttpMethod,
                                             java.util.regex.Pattern aLocatorRegExp,
                                             RestRequestObserver aRequestObserver)
        Registers a pre-configured RestEndpoint with the least required attributes and returns its instance. To unsubscribe via Observable.unsubscribeObserver(Object), use the returned instance. Attention: Invoke Openable.open() to activate this endpoint!
        Specified by:
        onRequest in interface RestServer
        Parameters:
        aHttpMethod - The HTTP-Method to which this RestEndpoint is bound. A value of null means that any HTTP-Method may trigger this RestEndpoint.
        aLocatorRegExp - The local locator (regular expression) pattern to which this RestEndpoint is bound. A value of null means that any locator may trigger this RestEndpoint.
        aRequestObserver - The listener processing a request targeted at this RestEndpoint.
        Returns:
        The pre-configured RestEndpoint which acts as handle to unsubscribe the RestEndpoint via Observable.unsubscribeObserver(Object).
      • onRequest

        public RestEndpointBuilder onRequest​(java.util.regex.Pattern aLocatorRegExp,
                                             RestRequestObserver aRequestObserver)
        Registers a pre-configured RestEndpoint, triggerd by any HTTP method, and returns its instance. To unsubscribe via Observable.unsubscribeObserver(Object), use the returned instance. Attention: Invoke Openable.open() to activate this endpoint!
        Specified by:
        onRequest in interface RestServer
        Parameters:
        aLocatorRegExp - The local locator (regular expression) pattern to which this RestEndpoint is bound.
        aRequestObserver - The listener processing a request targeted at this RestEndpoint.
        Returns:
        The pre-configured RestEndpoint which acts as handle to unsubscribe the RestEndpoint via Observable.unsubscribeObserver(Object).
      • onRequest

        public boolean onRequest​(RestEndpoint aRestEndpoint)
        For the sake of unified naming, this method just delegates to Observable.subscribeObserver(Object).
        Specified by:
        onRequest in interface RestServer
        Parameters:
        aRestEndpoint - the rest endpoint
        Returns:
        true, if successful
      • open

        public void open​(int aPort)
                  throws org.refcodes.component.OpenException
        Opens the HTTP sever connection (socket) at the given port
        Specified by:
        open in interface HttpRestServer
        Parameters:
        aPort - The port on which to listen for requests.
        Throws:
        org.refcodes.component.OpenException - thrown in case something went wrong such as the port being already in use.
      • open

        public void open​(int aPort,
                         int aMaxConnections)
                  throws org.refcodes.component.OpenException
        Opens the HTTP sever connection (socket) at the given port allowing the given number of maximum connections at the same time.
        Specified by:
        open in interface HttpRestServer
        Parameters:
        aPort - The port on which to listen for requests.
        aMaxConnections - The number of maximum connections at the same time.
        Throws:
        org.refcodes.component.OpenException - thrown in case something went wrong such as the port being already in use.
      • open

        public void open​(java.lang.String aProtocol,
                         org.refcodes.security.KeyStoreDescriptor aStoreDescriptor,
                         int aPort)
                  throws org.refcodes.component.OpenException
        Same as HttpRestServer.open(String, KeyStoreDescriptor, int, int) but:
        • The number of maximum connections at the same time is decided upon by the implementations's default value.
        Specified by:
        open in interface HttpRestServer
        Parameters:
        aProtocol - The protocol to use, e.g. "TLS".
        aStoreDescriptor - The store descriptor describing your KeyStore required for HTTPS.
        aPort - The port on which to listen for requests.
        Throws:
        org.refcodes.component.OpenException - thrown in case something went wrong such as the port being already in use.
      • open

        public void open​(java.lang.String aProtocol,
                         org.refcodes.security.KeyStoreDescriptor aStoreDescriptor,
                         int aPort,
                         int aMaxConnections)
                  throws org.refcodes.component.OpenException
        Opens the HTTPS sever connection (socket) at the given port allowing the given number of maximum connections at the same time using the provided HTTPS configuration parameters.
        Specified by:
        open in interface HttpRestServer
        Parameters:
        aProtocol - The protocol to use, e.g. "TLS".
        aStoreDescriptor - The store descriptor describing your KeyStore required for HTTPS.
        aPort - The port on which to listen for requests.
        aMaxConnections - The number of maximum connections at the same time.
        Throws:
        org.refcodes.component.OpenException - thrown in case something went wrong such as the port being already in use.
      • openUnchecked

        public void openUnchecked​(org.refcodes.net.HttpServerContext aConnection)
        Specified by:
        openUnchecked in interface org.refcodes.component.ConnectionOpenable<B extends HttpRestServer>
      • setBaseLocator

        public void setBaseLocator​(java.lang.String aBaseLocator)
        Specified by:
        setBaseLocator in interface org.refcodes.net.BaseLocatorAccessor.BaseLocatorMutator
      • setRealm

        public void setRealm​(java.lang.String aRealm)
        Specified by:
        setRealm in interface org.refcodes.net.RealmAccessor.RealmMutator
      • setRequestCorrelation

        public void setRequestCorrelation​(boolean hasRequestCorrelation)
        Specified by:
        setRequestCorrelation in interface org.refcodes.runtime.RequestCorrelation<B extends HttpRestServer>
      • setSessionCorrelation

        public void setSessionCorrelation​(boolean hasSessionCorrelation)
        Specified by:
        setSessionCorrelation in interface org.refcodes.runtime.SessionCorrelation<B extends HttpRestServer>
      • subscribeObserver

        public boolean subscribeObserver​(RestEndpoint aObserver)
        Specified by:
        subscribeObserver in interface org.refcodes.observer.Observable<B extends HttpRestServer>
      • toMediaTypeFactory

        public org.refcodes.net.MediaTypeFactory toMediaTypeFactory​(org.refcodes.net.MediaType aMediaType)
        Specified by:
        toMediaTypeFactory in interface org.refcodes.net.MediaTypeFactoryLookup
      • unsubscribeObserver

        public boolean unsubscribeObserver​(RestEndpoint aObserver)
        Specified by:
        unsubscribeObserver in interface org.refcodes.observer.Observable<B extends HttpRestServer>
      • withClose

        public B withClose​()
                    throws org.refcodes.component.CloseException
        Specified by:
        withClose in interface org.refcodes.component.Closable.CloseBuilder<B extends HttpRestServer>
        Specified by:
        withClose in interface HttpRestServer
        Throws:
        org.refcodes.component.CloseException
      • withCloseIn

        public B withCloseIn​(int aCloseInMillis)
        Specified by:
        withCloseIn in interface org.refcodes.component.Closable.CloseBuilder<B extends HttpRestServer>
        Specified by:
        withCloseIn in interface HttpRestServer
      • withCloseUnchecked

        public B withCloseUnchecked​()
        Specified by:
        withCloseUnchecked in interface org.refcodes.component.Closable.CloseBuilder<B extends HttpRestServer>
      • withOpen

        public B withOpen​(org.refcodes.net.HttpServerContext aConnection)
                   throws org.refcodes.component.OpenException
        Specified by:
        withOpen in interface org.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<RestEndpoint,RestServer>
        Specified by:
        withOpen in interface HttpRestServer
        Throws:
        org.refcodes.component.OpenException
      • withOpenUnchecked

        public B withOpenUnchecked​(org.refcodes.net.HttpServerContext aConnection)
        Specified by:
        withOpenUnchecked in interface org.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<RestEndpoint,RestServer>
      • getMaxConnections

        public int getMaxConnections​()
        Specified by:
        getMaxConnections in interface org.refcodes.io.MaxConnectionsAccessor
      • getKeyStoreDescriptor

        public org.refcodes.security.KeyStoreDescriptor getKeyStoreDescriptor​()
        Specified by:
        getKeyStoreDescriptor in interface org.refcodes.security.KeyStoreDescriptorAccessor
      • setKeyStoreDescriptor

        public void setKeyStoreDescriptor​(org.refcodes.security.KeyStoreDescriptor aStoreDescriptor)
        Specified by:
        setKeyStoreDescriptor in interface org.refcodes.security.KeyStoreDescriptorAccessor.KeyStoreDescriptorMutator
      • setMaxConnections

        public void setMaxConnections​(int aMaxConnections)
        Specified by:
        setMaxConnections in interface org.refcodes.io.MaxConnectionsAccessor.MaxConnectionsMutator
      • setProtocol

        public void setProtocol​(java.lang.String aProtocol)
        Specified by:
        setProtocol in interface org.refcodes.net.SchemeAccessor.SchemeMutator
      • toProtocol

        public java.lang.String toProtocol​()
        Specified by:
        toProtocol in interface org.refcodes.net.SchemeAccessor