[jbossts-issues] [JBoss JIRA] (JBTM-3214) Add a BeanPopulator method to directly provide a config bean

Michael Musgrove (Jira) issues at jboss.org
Wed Oct 23 12:10:00 EDT 2019


Michael Musgrove created JBTM-3214:
--------------------------------------

             Summary: 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: Enhancement
          Components: Configuration
    Affects Versions: 5.9.8.Final
            Reporter: Michael Musgrove
            Assignee: Michael Musgrove
             Fix For: 5.9.8.Final


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.



--
This message was sent by Atlassian Jira
(v7.13.8#713008)


More information about the jbossts-issues mailing list