[MAGNOLIA-3079] ComponentProvider should lookup superclasses and interfaces of the required component Created: 13/Feb/10  Updated: 04/Nov/15  Resolved: 04/Nov/15

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

Type: Improvement Priority: Major
Reporter: Magnolia International Assignee: Unassigned
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
relation
is related to MAGNOLIA-3059 Unable to replace implementation of t... Closed
is related to MAGNOLIA-2569 Components: introduce dependency inje... Closed
is related to MAGNOLIA-2553 FactoryUtil: should return a proxy ob... 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   

If ComponentProvider.getSingleton(com.foo.SomeSubInterface.class) is called, and no component is registered specifically for com.foo.SomeSubInterface, the ComponentProvider should look up registration for parents of com.foo.SomeSubInterface (i.e com.foo.SomeInterface, if SomeSubInterface extends SomeInterface)

This should:

  • remove the need for casting when depending on a specific implementation:
    // instead of:
    SomeSubInterface z = (SomeSubInterface) Components.getSingleton(SomeInterface.class);
    // you should be able to do:
    SomeSubInterface z = Components.getSingleton(SomeSubInterface.class);
    // even if only SomeInterface was configured (i.e if there's only a property for com.foo.SomeInterface)
    
  • likewise, this should fix MAGNOLIA-3059 – TODO: insert details as to how/why


 Comments   
Comment by Jan Haderka [ 25/Feb/10 ]

And yet another incarnation of the same problem:
Changing DefaultI18nContentSupport to ETKI18nContentSupport on the fly causes the exception below even tho both implement required interface (but the cast is to the superclass of the Default... not to the I18nContentSupport interface.

java.lang.ClassCastException: info.magnolia.module.extendedtemplatingkit.i18n.ETKI18nContentSupport cannot be cast to info.magnolia.cms.i18n.AbstractI18nContentSupport
	info.magnolia.cms.i18n.DefaultI18nContentSupport$$EnhancerByCGLIB$$a2946d4f.determineLocale(<generated>)
	info.magnolia.cms.i18n.I18nContentSupportFilter.doFilter(I18nContentSupportFilter.java:60)
	info.magnolia.cms.filters.AbstractMgnlFilter.doFilter(AbstractMgnlFilter.java:70)
	info.magnolia.cms.filters.MgnlFilterChain.doFilter(MgnlFilterChain.java:82)
Comment by Magnolia International [ 26/Jan/11 ]

Probably becomes irrelevant with MAGNOLIA-2569

Comment by Michael Mühlebach [ 04/Nov/15 ]

Given the thousands of other issues we have open that are more highly requested, we won't be able to address this issue in the foreseeable future. Instead we will focus on issues with a higher impact, and more votes.
Thanks for taking the time to raise this issue. As you are no doubt aware this issue has been on our backlog for some time now with very little movement.
I'm going to close this to set expectations so the issue doesn't stay open for years with few updates. If the issue is still relevant please feel free to reopen it or create a new issue.

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