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

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

Re lazyloading.patch: Yeah the problem is that the PluginHolder.getPlugins() 
method does not return an Iterator<AbstractWebConsolePlugin> but an 
Iterator<PluginHolder.Plugin>. My fix is to return the expected iterator (so I 
create an internal class to provide the correct objects).

Another issue with my original patch is, that the WebConsolePlugin.getTilte() 
method calls the AbstractWebConsolePlugin.getServletName() method, which in 
turn calls AbstractWebConsolePlugin.getTitle() etc.etc. until 
StackOverFlowError. Fixing this with calling 
getServletConfig().getServletName() in the WebConsolePlugin.getTitle() method. 
This works because the ServletConfig is built from the service registration 
properties and the servlet name is set to the plugin title registration 
property.



> 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
>
>
> 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.

Reply via email to