Class LayeredContext<L extends LayerInterface,​P extends LayeredRequest,​R extends LayeredResponse>

    • Constructor Summary

      Constructors 
      Constructor Description
      LayeredContext​(java.lang.String... endPointPath)  
    • Method Summary

      Modifier and Type Method Description
      protected abstract P decode​(HttpRequest request)
      This implementation must create request package from http request.
      protected abstract HttpResponse encode​(R response, P request)
      This implementation must create a http response package from response layered package and request layered package.
      protected java.util.List<java.lang.String> getEndPointPath()
      Return the list of the paths of the end point.
      protected L getLayerInterface​(java.lang.String implementationName)
      This method must return the instance of the layer interface.
      protected java.util.List<java.lang.String> getResourcePath​(HttpRequest request)
      Return the list of paths skipping all the end point paths.
      protected abstract R onAction​(P request)
      The implementation of this method must resolve the interface with the layer.
      HttpResponse onContext​(HttpRequest request)
      This method is called when there comes a http package addressed to this context.
      protected HttpResponse onError​(HttpRequest request, java.lang.Throwable throwable)
      This method is called when there are any error on the context execution.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LayeredContext

        public LayeredContext​(java.lang.String... endPointPath)
    • Method Detail

      • getLayerInterface

        protected final L getLayerInterface​(java.lang.String implementationName)
        This method must return the instance of the layer interface.
        Parameters:
        implementationName - Name of the implementation founded
        Returns:
        Return the implementation founded.
        Throws:
        java.lang.IllegalArgumentException - if the implementation with the pointed name is not found.
      • getEndPointPath

        protected final java.util.List<java.lang.String> getEndPointPath()
        Return the list of the paths of the end point.
        Returns:
        List of the paths.
      • getResourcePath

        protected final java.util.List<java.lang.String> getResourcePath​(HttpRequest request)
        Return the list of paths skipping all the end point paths.
        Parameters:
        request - Http request.
        Returns:
        List of the resource path.
      • onContext

        public final HttpResponse onContext​(HttpRequest request)
        This method is called when there comes a http package addressed to this context.
        Specified by:
        onContext in class Context
        Parameters:
        request - All the request information.
        Returns:
        Return an object with all the response information.
      • onAction

        protected abstract R onAction​(P request)
        The implementation of this method must resolve the interface with the layer.
        Parameters:
        request - Request package.
        Returns:
        Response package.
      • onError

        protected HttpResponse onError​(HttpRequest request,
                                       java.lang.Throwable throwable)
        This method is called when there are any error on the context execution.
        Overrides:
        onError in class Context
        Parameters:
        request - All the request information.
        throwable - Throwable object, could be null.
        Returns:
        Return an object with all the response information.
      • decode

        protected abstract P decode​(HttpRequest request)
        This implementation must create request package from http request.
        Parameters:
        request - Http request.
        Returns:
        Layered request package.
      • encode

        protected abstract HttpResponse encode​(R response,
                                               P request)
        This implementation must create a http response package from response layered package and request layered package.
        Parameters:
        response - Layered response.
        request - Layered request.
        Returns:
        Http response.