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

Lazy initialization of plugins

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • webconsole-3.0.0
    • webconsole-3.1.0
    • Web Console
    • None

    Description

      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.

      Attachments

        1. SimpleWebConsoleFactory.java
          7 kB
          Felix Meschberger
        2. SimpleWebConsoleFactory.java
          5 kB
          Valentin Valchev
        3. lazyloading.patch
          32 kB
          Valentin Valchev
        4. FELIX-2246.patch
          31 kB
          Felix Meschberger
        5. lazy-webconsole-plugins.png
          16 kB
          Valentin Valchev
        6. lazy-webconsole-plugins.jude
          11 kB
          Valentin Valchev

        Issue Links

          Activity

            People

              fmeschbe Felix Meschberger
              v_valchev Valentin Valchev
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: