Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-6310

Get org.osgi.service.http.HttpService reference at start of bundle

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Won't Fix
    • None
    • None
    • HTTP Service
    • None
    • Windows 10

      org.apache.felix.framework-6.0.3

      osgi.cmpn-7.0.0
      javax.servlet-3.1.0

      apache cxf 3.3.5

    Description

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            Justin_Li Justin Li
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: