public void addNotificationHandler(String serviceName, NotificationHandler handler){

        if(handler == null || serviceName == null || serviceName.isEmpty()){
            throw new IllegalArgumentException();
        }

        synchronized(notificationHandlers){
            if(! notificationHandlers.containsKey(serviceName)){
                notificationHandlers.put(serviceName, new ArrayList<NotificationHandler>());
            }

            notificationHandlers.get(serviceName).add(handler);
        }
    }
public void addNotificationHandler ( String serviceName , NotificationHandler handler ) { if ( handler == null || serviceName == null || serviceName . isEmpty ( ) ) { throw new IllegalArgumentException ( ) ; } synchronized ( notificationHandlers ) { if ( ! notificationHandlers . containsKey ( serviceName ) ) { notificationHandlers . put ( serviceName , new ArrayList < NotificationHandler > ( ) ) ; } notificationHandlers . get ( serviceName ) . add ( handler ) ; } }
Add a NotificationHandler to the Service.

This method can check the duplicate NotificationHandler for the serviceName, if the NotificationHandler
already exists in the serviceName, do nothing.

Throw IllegalArgumentException if serviceName or handler is null.

@param serviceName
the service name.
@param handler
the NotificationHandler for the service.