Package org.restlet.ext.osgi
Class BaseApplicationProvider
- java.lang.Object
-
- org.restlet.ext.osgi.BaseApplicationProvider
-
- All Implemented Interfaces:
ApplicationProvider
public class BaseApplicationProvider extends java.lang.Object implements ApplicationProvider
This class provides an implementation ofApplicationProvider
. 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
-
-
Field Summary
-
Fields inherited from interface org.restlet.ext.osgi.ApplicationProvider
SERVLET_CONFIG_ATTRIBUTE, SERVLET_CONTEXT_ATTRIBUTE
-
-
Constructor Summary
Constructors Constructor Description BaseApplicationProvider()
-
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 boundvoid
bindRouterProvider(RouterProvider routerProvider)
Called by OSGi DS to inject the router provider serviceorg.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 toHttpService.registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context)
when the servlet is registered.org.restlet.Application
getApplication()
Accessor for the cached application instanceorg.osgi.service.http.HttpContext
getContext()
The context is passed toHttpService.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 toHttpService.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
-
-
-
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 interfaceApplicationProvider
- 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 toHttpService.registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context)
when the servlet is registered.- Specified by:
getAlias
in interfaceApplicationProvider
- 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 toHttpService.registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context)
when the servlet is registered.- Specified by:
getContext
in interfaceApplicationProvider
- 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 toHttpService.registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context)
when the servlet is registered.- Specified by:
getInitParms
in interfaceApplicationProvider
- 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
-
-