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

Model classes are not instantiated by Guice.

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Won't Do
    • Neutral
    • None
    • 5.4.4
    • core
    • None

    Description

      A component will be instantiated by guice, so they can also be scanned for interceptors. This however is not valid for model classes themselves.

      I discovered this when I naively set a @CacheResult annotation on a method in a model class too (using https://github.com/vpro/jsr107-magnolia)

      A component which we wire in a model class gets instantiated in com.google.inject.internal.ConstructorInjector#line 85

          try {
              Object[] parameters = SingleParameterInjector.getAll(errors, context, parameterInjectors);
              t = constructionProxy.newInstance(parameters);
              constructionContext.setProxyDelegates(t);
            } finally {
      

      The model itself gets instantiated like this in info.magnolia.objectfactory.ObjectManufacturer#line line 118

       private Object newInstance(Constructor constructor, Object[] parameters) {
              try {
                  return constructor.newInstance(parameters);
              } catch (InstantiationException e) {
                  throw new MgnlInstantiationException(e);
              } catch (IllegalAccessException e) {
                  throw new MgnlInstantiationException(e);
              } catch (InvocationTargetException e) {
                  throw new MgnlInstantiationException(e);
              }
          }
      

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              Unassigned Unassigned
              mihxil Michiel Meeuwissen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Task DoD