[MAGNOLIA-6091] Use injection in ConfiguredTemplateDefinition Created: 18/Feb/15  Updated: 18/Mar/15  Resolved: 27/Feb/15

Status: Closed
Project: Magnolia
Component/s: rendering
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Neutral
Reporter: Espen Jervidalo Assignee: Espen Jervidalo
Resolution: Not an issue Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
relation
is related to MAGNOLIA-5053 The default TemplateAvailability valu... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:

 Description   

Using injection allows us to use the ConfiguredTemplateDefinition without having to inherit it just for defining a custom template availability.
The empty constructor is sadly not just deprecated, but needed for the beanmerge mechanism in rendering.



 Comments   
Comment by Magnolia International [ 18/Feb/15 ]

So your fix actually doesn't use injection, since it uses Components.getComponent. I'm also concerned that we'd need to do this sort of patch of anything that currently uses injection and gets proxied. I have a vague memory of facing something similar with the i18n mechanism we implemented in 5.2, which also uses proxies. Maybe there's a hint there about we could potentially "customize" the way the proxy creates the instance.
But, further:

  • This is a reminder of why all definitions need to be interfaces. The reason the proxy creation failed is because we're proxying a concrete class.
  • I'm really not convinced injecting TemplateAvailibility here is correct. It seems to be used as a default, which can be overriden by configuration. IMO, it should be injected in the usage point (e.g. MetaDataBasedTemplateDefinitionAssignment), which should use the configured TA or fallback to its injected one.

That said, I made a bunch of assumptions to understand your use-case, so let's check this out
(did you have a subclass of CAD just to set a custom TA, but without configuring it ?)

Comment by Espen Jervidalo [ 27/Feb/15 ]

the problem I tried to solve with this was fixed in bca57ac3ffed21a1c10c03a5941b30000eab3aaf of new site module. Closing this ticket a obsolete.

Generated at Mon Feb 12 04:11:13 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.