|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.clazzes.util.http.osgi.HttpServiceRegistrationListener
public class HttpServiceRegistrationListener
This class acts as a registration listener for the OSGi HttpServer and is used to export resources and servlets on the supplied http service.
It is recommended to use this class in a blueprint container like in the following example:
<bean id="listener" class="org.clazzes.util.http.osgi.HttpServiceRegistrationListener"> <property name="httpContext" ref="httpContext"/> <property name="servlets"> <map> <entry key="/foobar/servlet1" value-ref="servlet1"/> <entry key="/foobar/servlet2" value-ref="servlet3"/> </map> </property> <property name="resources"> <map> <entry key="/foobar" value="/foobar-resources"/> </map> </property> </bean>
This example make use of the previously defined BasicHttpContext
bean, which
you will find in the documentation of this class. If you like to export resources
in compressed form, please register a ResourceServlet
instance in the list
of servlets instead of a resource.
Please do not forget to manually import the org.clazzes.util.http.osgi
package in blueprint bundles, otherwise you will run into ClassNotFoundException
s.
Constructor Summary | |
---|---|
HttpServiceRegistrationListener()
|
Method Summary | |
---|---|
org.osgi.service.http.HttpContext |
getHttpContext()
|
Dictionary<String,String> |
getInitparams()
|
Map<String,String> |
getResources()
|
Map<String,javax.servlet.Servlet> |
getServlets()
|
void |
httpServiceBound(org.osgi.service.http.HttpService httpService)
The registration callback, which is called when the HttpService becomes available. |
void |
httpServiceUnbound(org.osgi.service.http.HttpService httpService)
The deregistration callback, which is called when the HttpService gets out of service. |
void |
setHttpContext(org.osgi.service.http.HttpContext httpContext)
|
void |
setInitparams(Dictionary<String,String> initparams)
|
void |
setResources(Map<String,String> resources)
|
void |
setServlets(Map<String,javax.servlet.Servlet> servlets)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HttpServiceRegistrationListener()
Method Detail |
---|
public void httpServiceBound(org.osgi.service.http.HttpService httpService) throws javax.servlet.ServletException, org.osgi.service.http.NamespaceException
httpService
- The HttpService where to register the supplied servlets and resources.
javax.servlet.ServletException
- As thrown by HttpService.registerServlet(String, Servlet, Dictionary, HttpContext)
.
org.osgi.service.http.NamespaceException
- As thrown by
HttpService.registerServlet(String, Servlet, Dictionary, HttpContext)
or
HttpService.registerResources(String, String, HttpContext)
.public void httpServiceUnbound(org.osgi.service.http.HttpService httpService)
httpService
- The httpService, which is going to be unavailable.public Map<String,javax.servlet.Servlet> getServlets()
public void setServlets(Map<String,javax.servlet.Servlet> servlets)
servlets
- the map of servlets to register with their aliases as keys to set.public Map<String,String> getResources()
public void setResources(Map<String,String> resources)
resources
- the map of resource paths to register with their aliases as keys to set.
If you need to deliver resources in compressed form, consider
registering a ResourceServlet
as an ordinary servlet.public Dictionary<String,String> getInitparams()
HttpService.registerServlet(String, Servlet, Dictionary, HttpContext)
when registering servlets.public void setInitparams(Dictionary<String,String> initparams)
initparams
- the optional initialization parameters passed to
HttpService.registerServlet(String, Servlet, Dictionary, HttpContext)
when registering servlets to set.public org.osgi.service.http.HttpContext getHttpContext()
null
, DefaultHttpContext.getInstance()
is used for reigstering servlets and resources.public void setHttpContext(org.osgi.service.http.HttpContext httpContext)
httpContext
- The HttpContext used to register servlets and resources to set.
If you need control over MIME types consider using a
BasicHttpContext
. If set
to null
, DefaultHttpContext.getInstance()
is used for registering servlets and resources.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |