Class OSGiMainHandler

java.lang.Object
org.glassfish.grizzly.http.server.HttpHandler
org.glassfish.grizzly.osgi.httpservice.OSGiMainHandler
All Implemented Interfaces:
OSGiHandler

public class OSGiMainHandler extends org.glassfish.grizzly.http.server.HttpHandler implements OSGiHandler
OSGi Main HttpHandler.

Dispatching HttpHandler. Grizzly integration.

Responsibilities:

  • Manages registration data.
  • Dispatching HttpHandler.service(Request, Response) method call to registered HttpHandlers.
Author:
Hubert Iwaniuk
  • Constructor Details

    • OSGiMainHandler

      public OSGiMainHandler(Logger logger, org.osgi.framework.Bundle bundle)
      Constructor.
      Parameters:
      logger - Logger utility.
      bundle - Bundle that we create if for, for local data reference.
  • Method Details

    • service

      public void service(org.glassfish.grizzly.http.server.Request request, org.glassfish.grizzly.http.server.Response response) throws Exception
      Service method dispatching to registered handlers.

      Specified by:
      service in class org.glassfish.grizzly.http.server.HttpHandler
      Throws:
      Exception
    • registerServletHandler

      public void registerServletHandler(String alias, javax.servlet.Servlet servlet, Dictionary initparams, org.osgi.service.http.HttpContext context, org.osgi.service.http.HttpService httpService) throws org.osgi.service.http.NamespaceException, javax.servlet.ServletException
      Registers OSGiServletHandler in OSGi Http Service.

      Keeps truck of all registrations, takes care of thread safety.

      Parameters:
      alias - Alias to register, if wrong value than throws NamespaceException.
      servlet - Servlet to register under alias, if fails to Servlet.init(javax.servlet.ServletConfig) throws ServletException.
      initparams - Initial parameters to populate ServletContext with.
      context - OSGi HttpContext, provides mime handling, security and bundle specific resource access.
      httpService - Used to HttpService.createDefaultHttpContext() if needed.
      Throws:
      org.osgi.service.http.NamespaceException - If alias was invalid or already registered.
      javax.servlet.ServletException - If Servlet.init(javax.servlet.ServletConfig) fails.
    • registerFilter

      public void registerFilter(javax.servlet.Filter filter, String urlPattern, Dictionary initparams, org.osgi.service.http.HttpContext context, org.osgi.service.http.HttpService httpService) throws javax.servlet.ServletException
      Parameters:
      filter -
      urlPattern -
      initparams -
      context -
      httpService -
      Throws:
      org.osgi.service.http.NamespaceException
      javax.servlet.ServletException
    • registerResourceHandler

      public void registerResourceHandler(String alias, org.osgi.service.http.HttpContext context, String internalPrefix, org.osgi.service.http.HttpService httpService) throws org.osgi.service.http.NamespaceException
      Registers OSGiResourceHandler in OSGi Http Service.

      Keeps truck of all registrations, takes care of thread safety.

      Parameters:
      alias - Alias to register, if wrong value than throws NamespaceException.
      context - OSGi HttpContext, provides mime handling, security and bundle specific resource access.
      internalPrefix - Prefix to map request for this alias to.
      httpService - Used to HttpService.createDefaultHttpContext() if needed.
      Throws:
      org.osgi.service.http.NamespaceException - If alias was invalid or already registered.
    • unregisterAlias

      public void unregisterAlias(String alias)
      Unregisters previously registered alias.

      Keeps truck of all registrations, takes care of thread safety.

      Parameters:
      alias - Alias to unregister, if not owning alias IllegalArgumentException is thrown.
      Throws:
      IllegalArgumentException - If alias was not registered by calling bundle.
    • unregisterFilter

      public void unregisterFilter(javax.servlet.Filter filter)
    • uregisterAllLocal

      public void uregisterAllLocal()
      Unregisters all aliases registered by owning bundle.
    • unregisterAll

      public void unregisterAll()
      Part of Shutdown sequence. Unregister and clean up.
    • getProcessingLock

      public ReentrantReadWriteLock.ReadLock getProcessingLock()
      Processing lock.

      ReentrantReadWriteLock.ReadLock can be obtained by concurrent threads at the same time.

      Specified by:
      getProcessingLock in interface OSGiHandler
      Returns:
      Processing lock.
    • getRemovalLock

      public ReentrantReadWriteLock.WriteLock getRemovalLock()
      Removal lock.

      ReentrantReadWriteLock.WriteLock can be obtained only by one thread, blocks OSGiHandler.getProcessingLock().

      Specified by:
      getRemovalLock in interface OSGiHandler
      Returns:
      Removal lock.
      See Also: