Uploaded image for project: 'Qpid'
  1. Qpid
  2. QPID-8670

Please provide an explicit method of passing in providers

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • qpid-java-broker-9.2.0
    • None
    • Broker-J
    • None

    Description

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            io7m Mark Raynsford
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: