felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Meschberger <fmesc...@gmail.com>
Subject Re: [jira] Commented: (FELIX-2246) Lazy initialization of plugins
Date Wed, 07 Apr 2010 12:54:53 GMT

On 07.04.2010 14:41, Valentin Valchev (JIRA) wrote:
> lazy wiring? If i have a bundle A exporting packages:
> a
> a.b
> And Bundle B importing
> a.b
> Will the framework try to resolve only a.b dependency or the whole bundle? (All package

No, it will really only resolve a.b (if you do Import-Package).

The question of when resolution takes place is controlled by two
aspects: When the Bundle classloader is created and how the imports are

The Bundle classloader is created when the bundle is resolved. At this
time all imports defined by the Import-Package header are resolved.

Imports defined by the DynamicImport-Package header are only resolved on
demand when they are really needed - on-demand or lazily.

So, if you have a plugin, which defines the o.a.f.webconsole package as
a dynamic import you might not want to have this import resolved until
when the plugin is really instantiated.

By moving the SimpleWebConsoleFactory class in its own package we help
with two issues:

  * We can embed the class in the plugin bundle, without creating a
    split-package situation.
  * We can still lazily wire to the o.a.f.webconsole package on-demand
    when the actual plugin is really instantiated.

Does this answer the question ? Or did I misunderstand the question ?


>> 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
>>            Assignee: Felix Meschberger
>>         Attachments: FELIX-2246.patch, lazy-webconsole-plugins.jude, lazy-webconsole-plugins.png,
lazyloading.patch, SimpleWebConsoleFactory.java, SimpleWebConsoleFactory.java
>> 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.

View raw message