Class BaseApplicationProvider

  • All Implemented Interfaces:
    ApplicationProvider

    public class BaseApplicationProvider
    extends java.lang.Object
    implements ApplicationProvider
    This class provides an implementation of ApplicationProvider. You register this class as an OSGi declarative service. The service declaration should look like:

     
     <?xml version="1.0" encoding="UTF-8"?>
     <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.example.app">
       <implementation class="org.restlet.ext.osgi.BaseApplicationProvider"/>
       <property name="alias" type="String" value="/"/>
       <reference bind="bindRouterProvider" cardinality="1..1" interface="org.restlet.ext.osgi.RouterProvider" name="RouterProvider" policy="static" unbind="unbindRouterProvider"/>
       <service>
         <provide interface="org.restlet.ext.osgi.ApplicationProvider"/>
       </service>
     </scr:component>
     
     

    The service properties are:

    • alias - the application alias registered with the http service

    The referenced services are:

    • RouterProvider - policy="static" cardinality="1..1"

    The provided services are:

    • ApplicationProvider

    Author:
    Bryan Hunt
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void activate​(org.osgi.service.component.ComponentContext context)
      Called by OSGi DS to activate the service after the router provider has been bound
      void bindRouterProvider​(RouterProvider routerProvider)
      Called by OSGi DS to inject the router provider service
      org.restlet.Application createApplication​(org.restlet.Context context)  
      protected org.restlet.Application doCreateApplication​(org.restlet.Context context)
      Called to construct the actual application instance.
      java.lang.String getAlias()
      The alias is passed to HttpService.registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context) when the servlet is registered.
      org.restlet.Application getApplication()
      Accessor for the cached application instance
      org.osgi.service.http.HttpContext getContext()
      The context is passed to HttpService.registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context) when the servlet is registered.
      java.util.Dictionary<java.lang.String,​java.lang.Object> getInitParms()
      The parameters are passed to HttpService.registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context) when the servlet is registered.
      void unbindRouterProvider​(RouterProvider routerProvider)
      Called by OSGi DS to un-inject the router provider service
      • Methods inherited from class java.lang.Object

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

      • BaseApplicationProvider

        public BaseApplicationProvider()
    • Method Detail

      • activate

        public void activate​(org.osgi.service.component.ComponentContext context)
        Called by OSGi DS to activate the service after the router provider has been bound
        Parameters:
        context - the OSGi component context
      • bindRouterProvider

        public void bindRouterProvider​(RouterProvider routerProvider)
        Called by OSGi DS to inject the router provider service
        Parameters:
        routerProvider - the router provider service
      • createApplication

        public org.restlet.Application createApplication​(org.restlet.Context context)
        Specified by:
        createApplication in interface ApplicationProvider
        Returns:
        the application to be register at the specified alias.
      • doCreateApplication

        protected org.restlet.Application doCreateApplication​(org.restlet.Context context)
        Called to construct the actual application instance. Extenders will generally override this method.
        Parameters:
        context - the Restlet application context
        Returns:
        the newly constructed application instance
      • getAlias

        public java.lang.String getAlias()
        Description copied from interface: ApplicationProvider
        The alias is passed to HttpService.registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context) when the servlet is registered.
        Specified by:
        getAlias in interface ApplicationProvider
        Returns:
        the alias used to register with the server servlet.
      • getApplication

        public org.restlet.Application getApplication()
        Accessor for the cached application instance
        Returns:
        the application
      • getContext

        public org.osgi.service.http.HttpContext getContext()
        Description copied from interface: ApplicationProvider
        The context is passed to HttpService.registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context) when the servlet is registered.
        Specified by:
        getContext in interface ApplicationProvider
        Returns:
        the context to use with the server servlet.
      • getInitParms

        public java.util.Dictionary<java.lang.String,​java.lang.Object> getInitParms()
        Description copied from interface: ApplicationProvider
        The parameters are passed to HttpService.registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context) when the servlet is registered.
        Specified by:
        getInitParms in interface ApplicationProvider
        Returns:
        the initialization parameters to use with the server servlet.
      • unbindRouterProvider

        public void unbindRouterProvider​(RouterProvider routerProvider)
        Called by OSGi DS to un-inject the router provider service
        Parameters:
        routerProvider - the router provider service