Justin Li created FELIX-6310:
--------------------------------
Summary: Get org.osgi.service.http.HttpService reference at start
of bundle
Key: FELIX-6310
URL: https://issues.apache.org/jira/browse/FELIX-6310
Project: Felix
Issue Type: Task
Components: HTTP Service
Environment: Windows 10
org.apache.felix.framework-6.0.3
osgi.cmpn-7.0.0
javax.servlet-3.1.0
apache cxf 3.3.5
Reporter: Justin Li
Our development requirement needs us to get the
org.osgi.service.http.HttpService reference during the activation of our
bundle, but the tests show the HttpService reference is always null if we want
to locate it from the bundle context.
The following is a simple example. "myServlet" is registered by calling
"bundleContext.registerService" with whiteboard pattern. According to tests, we
do get the org.osgi.service.http.HttpService reference by registering a
ServiceListener , but the HttpService reference is not ready unless we REALLY
make a web call to the web service itself. Actually the dumped HttpService is
an org.apache.felix.http.base.internal.service.*PerBundleHttpServiceImpl*
object. So, it seems the HttpService is lazy started.
We do not want the HttpService to be lazy started. The question is, is there
any config or setting can be used so that when bundleContext.registerService()
is called the HttpService reference will also be ready? Thanks.
@Activate
public void activate(ComponentContext ctx) {
... ...
BundleContext bundleContext = ctx.getBundleContext();
Hashtable<String, String> params = new Hashtable<>();
params.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN,
"/currentView.*");
... ...
bundleContext.registerService(Servlet.class, myServlet, params);
Regards.
Justin
... ...
}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)