Class GrizzlyRestServicePublishService.MainHttpHandler

  • Enclosing class:
    GrizzlyRestServicePublishService

    public static class GrizzlyRestServicePublishService.MainHttpHandler
    extends org.glassfish.grizzly.http.server.HttpHandler
    Main handler dealing with incoming request more intelligently than Grizzly does.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<Tuple2<java.lang.String,​java.lang.String>,​Tuple2<java.lang.String,​org.glassfish.grizzly.http.server.HttpHandler>> subhandlercache
      Published subhandler matching cache.
      protected java.util.Map<Tuple2<java.lang.String,​java.lang.String>,​Tuple2<java.lang.String,​org.glassfish.grizzly.http.server.HttpHandler>> subhandlers
      Published subhandlers.
    • Constructor Summary

      Constructors 
      Constructor Description
      MainHttpHandler()
      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, org.glassfish.grizzly.http.server.HttpHandler 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,​org.glassfish.grizzly.http.server.HttpHandler> findSubhandler​(java.lang.String host, java.lang.String path)
      Locates an appropriate subhandler that matches the requested resource closely.
      boolean isEmpty()
      Tests if the handler contains no subhandlers.
      void removeSubhandler​(java.lang.String vhost, java.lang.String path)  
      void service​(org.glassfish.grizzly.http.server.Request request, org.glassfish.grizzly.http.server.Response resp)
      Service the request.
      • Methods inherited from class org.glassfish.grizzly.http.server.HttpHandler

        destroy, getErrorPageGenerator, getName, getRequestExecutorProvider, getRequestURIEncoding, getSessionCookieName, getSessionManager, isAllowCustomStatusMessage, isAllowEncodedSlash, sendAcknowledgment, setAllowCustomStatusMessage, setAllowEncodedSlash, setDecodeUrl, setDispatcherHelper, setRequestURIEncoding, setRequestURIEncoding, start, updatePaths
      • Methods inherited from class java.lang.Object

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

      • subhandlers

        protected java.util.Map<Tuple2<java.lang.String,​java.lang.String>,​Tuple2<java.lang.String,​org.glassfish.grizzly.http.server.HttpHandler>> 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,​org.glassfish.grizzly.http.server.HttpHandler>> subhandlercache
        Published subhandler matching cache.
    • Constructor Detail

      • MainHttpHandler

        public MainHttpHandler()
        Create the handler.
    • Method Detail

      • service

        public void service​(org.glassfish.grizzly.http.server.Request request,
                            org.glassfish.grizzly.http.server.Response resp)
                     throws java.lang.Exception
        Service the request.
        Specified by:
        service in class org.glassfish.grizzly.http.server.HttpHandler
        Throws:
        java.lang.Exception
      • addSubhandler

        public void addSubhandler​(java.lang.String vhost,
                                  java.lang.String path,
                                  org.glassfish.grizzly.http.server.HttpHandler subhandler)
        Adds a new subhandler.
        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.
        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)
        Parameters:
        vhost - Virtual host specification.
        path - Path being handled.
      • findSubhandler

        protected Tuple2<java.lang.String,​org.glassfish.grizzly.http.server.HttpHandler> 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.