[MAGNOLIA-4760] Add support for @PostConstruct Created: 04/Jan/13  Updated: 18/Feb/15  Resolved: 11/Mar/13

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

Type: Improvement Priority: Neutral
Reporter: Tobias Mattsson Assignee: Tobias Mattsson
Resolution: Fixed Votes: 0
Labels: ioc
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to MAGNOLIA-6074 Config file watch service should shut... Closed
causality
supersession
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   

We can support @PostConstruct (JSR250) using mycila-guice. A third party library that adds JSR250 support to Guice.

While we had issues with @PreDestroy not working properly support for @PostConstruct was reliable and can be introduced to the code base.



 Comments   
Comment by Tobias Mattsson [ 04/Jan/13 ]

Added support for @PostConstruct using mycila-guice version 2.10.ga.

Comment by Jan Haderka [ 25/Jan/13 ]

Would you be able to guess purpose of having LifecycleExtendsClassWithPackageProtectedMethodsInOtherPackage.java from reading the class name? ... I'm afraid that after reading the name anyone will end up with more questions then answers so it might be better to use less explicit and easier to remember/use name. We have already LifecycleMultiple and LifecycleExtends so I think LifecycleExtendsPackage or LifecycleExtendsDefault would be more than enough. Similarly LifecyclePackageProtectedMethod could be just LifecyclePackageMethod.

Comment by Tobias Mattsson [ 20/Feb/13 ]

Well, its used to test the specific case when you extend a class that has package protected methods and is in another package than your class. Its a special case where you're unable to override such a method and therefore if your method is annotated and the method in the base class is also annotated then both will be called. It's part of the JSR-250 spec and PicoContainer failed to live up to that. That's why I initially added these extensive tests.

No one will ever use these classes for anything else than tests.

Their names are intentionally long and explicit to explain why they're needed.

Would it help if I improved the javadoc?

Comment by Jan Haderka [ 20/Feb/13 ]

yeah, if javadoc explicitly states that then I can live with the names (tho i still dislike those long names )

Comment by Tobias Mattsson [ 20/Feb/13 ]

Added more javadoc throughout these classes and the test.

Comment by Milan Divilek [ 11/Mar/13 ]

Reopen: Missing port of https://git.magnolia-cms.com/gitweb/?p=magnolia_main.git;a=commit;h=d7fa4e9670d756eb2f3cfe29b7ce52c00a1e450c

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