Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Changed order of injection types (constructor first)

...

In order to remain fully backwards compatible, Magnolia 4.5 will add both a component definition and a type mapping for AggregationState.

Supported

...

types of dependency injection

Magnolia uses the standardized annotations for dependency injections from JSR-330 which enable all three forms types of dependency injection:

  • Constructor injection
  • Setter Field injectionField
  • Setter injection

This is an example of all three:

Code Block
public class RenderingEngine {

    @Inject
// Dependencies are injected privatein TemplateRegistrythe templateRegistry;
constructor
    @Inject
    public SomeComponent(ModuleManager moduleManager) { ... }

    // Fields are set with injected dependencies after construction
    @Inject
    private TemplateRegistry templateRegistry;

    // Setters are called with injected dependencies after construction
    @Inject
    public void setRendererRegistry(RendererRegistry rendererRegistry) { ... }
}

...