]
Michael Musgrove updated JBTM-3214:
-----------------------------------
Parent: JBTM-3209
Issue Type: Sub-task (was: Enhancement)
Add a BeanPopulator method to directly provide a config bean
------------------------------------------------------------
Key: JBTM-3214
URL:
https://issues.jboss.org/browse/JBTM-3214
Project: JBoss Transaction Manager
Issue Type: Sub-task
Components: Configuration
Affects Versions: 5.9.8.Final
Reporter: Michael Musgrove
Assignee: Michael Musgrove
Priority: Optional
Fix For: 5.next
Narayana has quite a flexible mechanism for setting properties:
- it uses xml property files
- it reads Java system properties
- it initialises our config beans using reflection to call the setters
Some systems, Quarkus for example, have their own config mechanisms (MicroProfile Config
in the Quarkus example) so it makes sense to allow our beans to be configured directly
(avoiding parsing and reflection).
Implementation wise we do already have the PropertiesFactory class to directly provide
config properties but that code still uses reflection to set the actual property values
and besides, it is an abstract class so we cannot safely add new methods to it. My
proposal is to add a single method to the BeanPopulator class:
{code}
public static void setBeanInstance(String name, Object beanInstance) {
beanInstances.putIfAbsent(name, beanInstance);
}
{code}
This code avoids the use of reflection (and possibly xml parsing) whenever access to the
named bean is required. Note that this approach requires a user to know in advance which
environment beans Narayana is using.