You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Felix Meschberger (JIRA)" <ji...@apache.org> on 2010/04/02 16:44:27 UTC

[jira] Commented: (FELIX-2246) Lazy initialization of plugins

    [ https://issues.apache.org/jira/browse/FELIX-2246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12852838#action_12852838 ] 

Felix Meschberger commented on FELIX-2246:
------------------------------------------

Good idea. It actually has another potential advantage (theoretical, need to investigate): the service may be registered under the service name without the bundle actually being required to be wired to the webconsole API package thus also allowing the service to be registered before the web console is available and to be automatically "activated" when the web console is there and the service is needed.

There is one catch: To register a plugin, the web console requires two pieces of information: the plugin label (used to construct the URL to the plugin) and the plugin title (used to render the button to select the plugin).

Traditionally, the label must be provided when the service is registered while the title service registration property is optional. So some plugin services may not provide the title property and must be accessed to get the title.

So, we could implement this fully delayed behaviour for services, which provide both properties as service properties. For older plugins not providing the title property, we would still have to eagerly access the service.

> Lazy initialization of plugins
> ------------------------------
>
>                 Key: FELIX-2246
>                 URL: https://issues.apache.org/jira/browse/FELIX-2246
>             Project: Felix
>          Issue Type: Improvement
>          Components: Web Console
>    Affects Versions: webconsole-3.0.0
>            Reporter: Valentin Valchev
>         Attachments: lazy-webconsole-plugins.jude, lazy-webconsole-plugins.png
>
>
> Here at ProSyst we use a small trick to delay initialization of our services:
> When the service is quite big, and loads many resources (incl. too many classes), we register not a service, but a ServiceFactory instead. With that factory we delay the instantiation of the service, when it is actually needed and obtained by other bundle.
> Yes, this makes the code a little bit more complex, but it greatly improves the start-up time and the overall memory usage.
> This can be applied to webconsole plugins too. My idea is that Web Console should only track Service Reference without actually obtaining the service itself [not getService()].
> When the user makes request the WebConsole calls the factory to create instance. Instance is created and returned to the Web Console, which uses it to generate content for the request.
> This way a plugin is actually not initialized until it is really used. Only small portion of classes, from the bundle are initialized.
> Unfortunately the ServiceTracker, when notified for added service obtains the real service object. So it might be better to use directly ServiceListener for the plugins.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.