On Thu, Jul 23, 2020 at 8:59 AM Justin Li <justin...@kofax.com> wrote:
> 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. > You appear to be mixing HttpService and Http Whiteboard modes. Why do you need HttpService if you are registering your servlet as a service using bundleContext.registerService(Servlet.class, myServlet, params) ? - Ray > The following is an 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? > > > > @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); > > ... ... > > } > > > > Thanks. > > Justin > > > > *Justin Li* > Sr. Software Developer > > > > > *Kofax Canada, ULC*460 Phillip Street > Waterloo, ON N2L 5J2 > > Tel: +1 519 880 7543 > justin...@kofax.com > > > ------------------------------ > > This communication is only for the use of the intended recipient. It may > contain confidential or proprietary information. If you are not the > intended recipient or have received this communication in error, please > notify the sender via phone and destroy this communication immediately. > > -- *Raymond Augé* <http://www.liferay.com/web/raymond.auge/profile> (@rotty3000) Senior Software Architect *Liferay, Inc.* <http://www.liferay.com> (@Liferay)