Package jadex.extension.rs.publish
Class PathHandler
- java.lang.Object
-
- jadex.extension.rs.publish.PathHandler
-
- All Implemented Interfaces:
IPathHandler
,IRequestHandler
public class PathHandler extends java.lang.Object implements IPathHandler
Main handler dealing with incoming request.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<Tuple2<java.lang.String,java.lang.String>,Tuple2<java.lang.String,IRequestHandler>>
subhandlercache
Published subhandler matching cache.protected java.util.Map<Tuple2<java.lang.String,java.lang.String>,Tuple2<java.lang.String,IRequestHandler>>
subhandlers
Published subhandlers.
-
Constructor Summary
Constructors Constructor Description PathHandler()
Create the handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSubhandler(java.lang.String vhost, java.lang.String path, IRequestHandler subhandler)
Adds a new subhandler.boolean
containsSubhandlerForExactUri(java.lang.String vhost, java.lang.String path)
Tests if a handler for the exact URI is currently published.protected Tuple2<java.lang.String,IRequestHandler>
findSubhandler(java.lang.String host, java.lang.String path)
Locates an appropriate subhandler that matches the requested resource closely.java.util.Map<Tuple2<java.lang.String,java.lang.String>,Tuple2<java.lang.String,IRequestHandler>>
getSubhandlers()
Get the subhandlers.void
handleRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, java.lang.Object args)
Handle the request.boolean
isEmpty()
Tests if the handler contains no subhandlers.void
removeSubhandler(java.lang.String vhost, java.lang.String path)
Remove a subhandler.
-
-
-
Field Detail
-
subhandlers
protected java.util.Map<Tuple2<java.lang.String,java.lang.String>,Tuple2<java.lang.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 java.util.Map<Tuple2<java.lang.String,java.lang.String>,Tuple2<java.lang.String,IRequestHandler>> subhandlercache
Published subhandler matching cache. Adds already resolved handlers for requested paths.
-
-
Method Detail
-
handleRequest
public void handleRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, java.lang.Object args) throws java.lang.Exception
Handle the request.- Specified by:
handleRequest
in interfaceIRequestHandler
- Parameters:
request
- The request.response
- The response.args
- Container specific args.- Throws:
java.lang.Exception
-
addSubhandler
public void addSubhandler(java.lang.String vhost, java.lang.String path, IRequestHandler subhandler)
Adds a new subhandler.- Specified by:
addSubhandler
in interfaceIPathHandler
- Parameters:
vhost
- Virtual host specification.path
- Path being handled.subhandler
- The subhandler.
-
containsSubhandlerForExactUri
public boolean containsSubhandlerForExactUri(java.lang.String vhost, java.lang.String path)
Tests if a handler for the exact URI is currently published.- Specified by:
containsSubhandlerForExactUri
in interfaceIPathHandler
- 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(java.lang.String vhost, java.lang.String path)
Remove a subhandler.- Specified by:
removeSubhandler
in interfaceIPathHandler
- Parameters:
vhost
- Virtual host specification.path
- Path being handled.
-
findSubhandler
protected Tuple2<java.lang.String,IRequestHandler> findSubhandler(java.lang.String host, java.lang.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 java.util.Map<Tuple2<java.lang.String,java.lang.String>,Tuple2<java.lang.String,IRequestHandler>> getSubhandlers()
Get the subhandlers.- Specified by:
getSubhandlers
in interfaceIPathHandler
- Returns:
- The subhandlers
-
-