Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-6483

Introduce ReloadableClassFactory interface

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.4.5
    • Component/s: core
    • Labels:
      None
    • Release notes required:
      Yes
    • Sprint:
      Basel 27
    • Story Points:
      3
    • Magnolia Release:
      5.4.5

      Description

      Before M4.5 objects were instantiated using a ComponentProvider which eventually delegated to Classes.getClassFactory().newInstance(). With M4.5 IoC was introduced and the current ComponentProvider info.magnolia.objectfactory.guice.GuiceComponentProvider is no longer aware of the ClassFactory. However, as the DefaultClassFactory can be replaced with a custom one (like e.g. our Groovy module does) that means that instantiating new objects with a custom class factory no longer works. This particularly affects the Groovy module and its ability to replace Java classes in config with Groovy ones and hot deploy and change them on the fly.

      It was decided to make our current default ComponentProvider aware of ClassFactory again. This will happen through ObjectManufacturer which is eventually used to create class instances. The new interface will be implemented by custom class factories and ObjectManufacturer will call the interface's new method delegating to the custom cf which will try to re-load (by recompiling if necessary) the class.

      Some concerns were expressed as to a performance penalty due to this additional check but, as far as I could see in my basic measurements, the overload seems to be negligible.
      Here I am comparing the execution time of ObjectManufacturer.newInstance() with and without my changes. The table shows most of the classes instantiated by Magnolia when rendering the home page of the travel demo. The largest numbers are of course for the Groovy foo.TestModel class especially when it needs recompiling cause the source has changed (more precisely because it's newer).

      Class name execution time without changes with changes Groovy source changed (with changes)
      info.magnolia.context.DefaultRepositoryStrategy 0.10556 ms 1.553202 ms -
      info.magnolia.module.site.ExtendedAggregationState 0.023335 ms 0.01753 ms -
      info.magnolia.context.SystemRepositoryStrategy 0.091537 ms 0.096238 ms -
      info.magnolia.context.DefaultRepositoryStrategy 0.146448 ms 0.049374 ms -
      info.magnolia.module.site.ExtendedAggregationState 0.014709 ms 0.012665 ms -
      info.magnolia.rendering.util.FilteringAppendableWrapper 0.015895 ms 0.023665 ms -
      info.magnolia.rendering.engine.FilteringResponseOutputProvider 0.119688 ms 0.082204 ms -
      info.magnolia.rendering.listeners.AreaFilteringListener 0.122445 ms 0.102501 ms -
      info.magnolia.rendering.model.RenderingModelImpl 0.676595 ms 0.108454 ms -
      info.magnolia.context.SystemRepositoryStrategy 0.098068 ms 0.501442 ms -
      info.magnolia.templating.elements.PageElement 0.144661 ms 0.117432 ms -
      info.magnolia.templating.elements.AreaElement 0.218534 ms 0.063254 ms -
      info.magnolia.rendering.model.RenderingModelImpl 0.150412 ms 0.092489 ms -
      info.magnolia.templating.elements.AreaElement 0.188307 ms 0.11792 ms -
      foo.TestModel 0.393441 ms 5.328067 ms (overhead due to check if needs recompilation) 496.362892 ms (overhead due to check and recompilation)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                fgrilli Federico Grilli
                Reporter:
                fgrilli Federico Grilli
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Date of First Response:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 2d
                  2d