Components: introduce dependency injection (MAGNOLIA-2569)

[MAGNOLIA-4035] Revise content2bean Created: 09/Mar/12  Updated: 03/Dec/13  Resolved: 03/Dec/13

Status: Closed
Project: Magnolia
Component/s: content2bean, core
Affects Version/s: None
Fix Version/s: None

Type: Sub-task Priority: Neutral
Reporter: Tobias Mattsson Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Cloners
clones MAGNOLIA-3525 Support for using a custom TypeMappin... Closed
dependency
depends upon MAGNOLIA-3517 Module descriptor additions Closed
relation
is related to MAGNOLIA-3838 As we're moving away from Content-API... Closed
is related to MAGNOLIA-3599 IoC: pass the current component provi... Closed
is related to MAGNOLIA-2724 c2b: improve transformer discovery Closed
Template:

 Description   

Ideally, we should go for a much simpler interface:

public interface Content2Bean {
    Object toBean(Content node) throws Content2BeanException;
}

Sprinkle some generics magic on top of that, and nobody should (hopefully) have to specify the transformer they need anymore. There's probably going to be some sort of transformer registry somewhere, where transformers are able to tell what type(s) they're transforming.

Some (if not all) transformers will need to be explicitly registered (either just as "components" or explicitly as "transformers" - see MAGNOLIA-3517) Subclasses of CollectionPropertyHidingTransformer for instance, will probably need that.

Additional ideas:

  • Drop support for pluggable info.magnolia.content2bean.TypeMapping. Instead, module descriptors can explicitly register transformers. Neither PropertiesBasedTypeMapping nor DescriptorFileBasedTypeMapping was ever used, as far as we know.
  • Only support explicitly registered transformers. We might add another element to the module descriptor. (see MAGNOLIA-3517)
    • transformers would be in the root container ? can we "hide" them (i.e no components should depend on them, except TransformerProvider)?
  • Known non-core transformers:
    • info.magnolia.module.cache.ehcache.CacheConfigurationTransformer (registered via a .transformer property - this was needed because it transforms a non-magnolia class)
    • info.magnolia.module.cache.executor.CompositeExecutorTransformer (naming convention)
    • info.magnolia.imaging.operations.text.TextStyleTransformer (naming convention)
    • ProxyCapableContent2BeanTransformer and SpringContent2BeanTransformer in Blossom

Generated at Mon Feb 12 03:52:02 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.