Class PathHandler

java.lang.Object
jadex.publishservice.publish.PathHandler
All Implemented Interfaces:
IPathHandler, IRequestHandler

public class PathHandler extends Object implements IPathHandler
Main handler dealing with incoming request.
  • Field Details

    • subhandlers

      protected Map<jadex.common.Tuple2<String,String>,jadex.common.Tuple2<String,IRequestHandler>> subhandlers
      Published subhandlers. vhost+path -> path+httphandler Path needs to be preserved in the value since the cache does not preserve it.
    • subhandlercache

      protected Map<jadex.common.Tuple2<String,String>,jadex.common.Tuple2<String,IRequestHandler>> subhandlercache
      Published subhandler matching cache. Adds already resolved handlers for requested paths.
  • Constructor Details

    • PathHandler

      public PathHandler()
      Create the handler.
  • Method Details

    • handleRequest

      public void handleRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Object args) throws Exception
      Handle the request.
      Specified by:
      handleRequest in interface IRequestHandler
      Parameters:
      request - The request.
      response - The response.
      args - Container specific args.
      Throws:
      Exception
    • addSubhandler

      public void addSubhandler(String vhost, String path, IRequestHandler subhandler)
      Adds a new subhandler.
      Specified by:
      addSubhandler in interface IPathHandler
      Parameters:
      vhost - Virtual host specification.
      path - Path being handled.
      subhandler - The subhandler.
    • containsSubhandlerForExactUri

      public boolean containsSubhandlerForExactUri(String vhost, String path)
      Tests if a handler for the exact URI is currently published.
      Specified by:
      containsSubhandlerForExactUri in interface IPathHandler
      Parameters:
      vhost - Virtual host specification.
      path - Path being handled.
      Returns:
      True, if a handler was found.
    • isEmpty

      public boolean isEmpty()
      Tests if the handler contains no subhandlers.
      Returns:
      True, if no subhandlers remain.
    • removeSubhandler

      public void removeSubhandler(String vhost, String path)
      Remove a subhandler.
      Specified by:
      removeSubhandler in interface IPathHandler
      Parameters:
      vhost - Virtual host specification.
      path - Path being handled.
    • findSubhandler

      protected jadex.common.Tuple2<String,IRequestHandler> findSubhandler(String host, String path)
      Locates an appropriate subhandler that matches the requested resource closely.
      Parameters:
      host - The requested virtual host.
      path - The requested path
      Returns:
      The subhandler or null if none is found for the host.
    • getSubhandlers

      public Map<jadex.common.Tuple2<String,String>,jadex.common.Tuple2<String,IRequestHandler>> getSubhandlers()
      Get the subhandlers.
      Specified by:
      getSubhandlers in interface IPathHandler
      Returns:
      The subhandlers