You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Justin Li (Jira)" <ji...@apache.org> on 2020/07/22 05:23:00 UTC

[jira] [Updated] (FELIX-6310) Get org.osgi.service.http.HttpService reference at start of bundle

     [ https://issues.apache.org/jira/browse/FELIX-6310?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Justin Li updated FELIX-6310:
-----------------------------
    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

  was:
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

 

 

    ... ...
 }


> 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
>            Priority: Blocker
>
> 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)