Mark Raynsford created QPID-8670:
------------------------------------

             Summary: Please provide an explicit method of passing in providers
                 Key: QPID-8670
                 URL: https://issues.apache.org/jira/browse/QPID-8670
             Project: Qpid
          Issue Type: Improvement
          Components: Broker-J
    Affects Versions: qpid-java-broker-9.2.0
            Reporter: Mark Raynsford


Currently, the only way the broker can pick up "plugins" is via ServiceLoader. 
Specifically, it seems that all extensions to the broker must be provided by 
registering a provider as a service, and then the following code inside the 
SystemLauncher uses ServiceLoader to find it:

```
  private void startupImpl(Map<String,Object> systemConfigAttributes) throws 
Exception
    {
        populateSystemPropertiesFromDefaults((String) 
systemConfigAttributes.get(SystemConfig.INITIAL_SYSTEM_PROPERTIES_LOCATION));

        String storeType = (String) 
systemConfigAttributes.get(SystemConfig.TYPE);

        // Create the RootLogger to be used during broker operation
        boolean statusUpdatesEnabled = 
Boolean.parseBoolean(System.getProperty(SystemConfig.PROPERTY_STATUS_UPDATES, 
"true"));
        MessageLogger messageLogger = new 
LoggingMessageLogger(statusUpdatesEnabled);
        _eventLogger.setMessageLogger(messageLogger);


        PluggableFactoryLoader<SystemConfigFactory> configFactoryLoader = new 
PluggableFactoryLoader<>(SystemConfigFactory.class);
```

However, this is rather painful to deal with when we want to package Broker-J 
as part of a reusable library so that the broker can be embedded in other 
applications.

My use case is that I want to provide a very simplified API that doesn't expose 
any of Broker-J's APIs to the user. When the user starts a broker, they 
explicitly pass in a list of authentication providers that are implemented in 
terms of my simplified interfaces.

In the current world, the only way for new authentication providers to be added 
is if implementations of the ConfiguredObjectFactory type can be located by the 
Broker-J implementation via ServiceLoader. ServiceLoader is not dynamic (at 
least not without making the system completely incomprehensible).

I would really appreciate a method to pass in a list of ConfiguredObjectFactory 
values to the system rather than having it unconditionally find them via 
ServiceLoader. It would be fine if the explicit factories passed in were used 
in addition to anything found in ServiceLoader.

This would also, presumably, make testing easier: ServiceLoader is not the 
easiest thing in the world to mock due to being quite tied to the module system 
and other VM internals.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to