code: public static JsMessagingEngine[] registerMessagingEngineListener(
              final SibRaMessagingEngineListener listener, final String busName) {
  
          final String methodName = "registerMessagingEngineListener";
          if (TRACE.isEntryEnabled()) {
              SibTr.entry(TRACE, methodName, new Object[] { listener, busName });
          }
  
          final Set activeMessagingEngines = new HashSet();
  
          /*
           * Take lock on active messaging engines to ensure that the activation
           * of a messaging engine is reported once and once only either in the
           * array returned from this method or by notification to the listener.
           */
  
          synchronized (ACTIVE_MESSAGING_ENGINES) {
  
              synchronized (MESSAGING_ENGINE_LISTENERS) {
  
                  // Add listener to map
                  Set listeners = (Set) MESSAGING_ENGINE_LISTENERS.get(busName);
                  if (listeners == null) {
                      listeners = new HashSet();
                      MESSAGING_ENGINE_LISTENERS.put(busName, listeners);
                  }
                  listeners.add(listener);
  
              }
  
              if (busName == null) {
  
                  // Add all of the currently active messaging engines
                  for (final Iterator iterator = ACTIVE_MESSAGING_ENGINES
                          .values().iterator(); iterator.hasNext();) {
  
                      final Set messagingEngines = (Set) iterator.next();
                      activeMessagingEngines.addAll(messagingEngines);
  
                  }
  
              } else {
  
                  // Add active messaging engines for the given bus if any
                  final Set messagingEngines = (Set) ACTIVE_MESSAGING_ENGINES
                          .get(busName);
                  if (messagingEngines != null) {
                      activeMessagingEngines.addAll(messagingEngines);
                  }
  
              }
  
          }
  
          final JsMessagingEngine[] result = (JsMessagingEngine[]) activeMessagingEngines
                  .toArray(new JsMessagingEngine[activeMessagingEngines.size()]);
  
          if (TRACE.isEntryEnabled()) {
              SibTr.exit(TRACE, methodName, result);
          }
          return result;
  
      }
docs: Registers a listener for active messaging engines on a bus.
  
  @param listener
  the listener to register
  @param busName
  the name of the bus the listener wishes to be informed about
  messaging engines for or <code>null</code> if it wishes to
  know about all messaging engines
  @return an array of the currently active messaging engines or an empty
  array if there are none