/*
(non-Javadoc)

@seeorg.jdiameter.api.sh.ServerShSessionListener#
doSubscribeNotificationsRequestEvent
(org.jdiameter.api.sh.ServerShSession,
org.jdiameter.api.sh.events.SubscribeNotificationsRequest)
165200
@Override
  public void doSubscribeNotificationsRequestEvent(ServerShSession session, SubscribeNotificationsRequest request)
      throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
    // TODO Auto-generated method stub
  }
1028889
public void deliverEvent(AbstractTaskEvent event) {

		synchronized (this.subscriptions) {

			List<EventListener> subscribers = this.subscriptions.get(event.getClass());
			if (subscribers == null) {
				return;
			}

			final Iterator<EventListener> it = subscribers.iterator();
			while (it.hasNext()) {
				it.next().eventOccurred(event);
			}
		}
	}
430127
public void setEventSubscriptionsList(java.util.Collection<EventSubscription> eventSubscriptionsList) {
        if (eventSubscriptionsList == null) {
            this.eventSubscriptionsList = null;
            return;
        }

        this.eventSubscriptionsList = new java.util.ArrayList<EventSubscription>(eventSubscriptionsList);
    }
609614
protected void sendNotification(ResourceDeliveryMessage theMsg) {
		Map<String, List<String>> params = new HashMap<>();
		List<Header> headers = new ArrayList<>();
		if (theMsg.getSubscription().getHeaders() != null) {
			theMsg.getSubscription().getHeaders().stream().filter(Objects::nonNull).forEach(h -> {
				final int sep = h.indexOf(':');
				if (sep > 0) {
					final String name = h.substring(0, sep);
					final String value = h.substring(sep + 1);
					if (StringUtils.isNotBlank(name)) {
						headers.add(new Header(name.trim(), value.trim()));
					}
				}
			});
		}

		StringBuilder url = new StringBuilder(theMsg.getSubscription().getEndpointUrl());
		IHttpClient client = myFhirContext.getRestfulClientFactory().getHttpClient(url, params, "", RequestTypeEnum.POST, headers);
		IHttpRequest request = client.createParamRequest(myFhirContext, params, null);
		try {
			IHttpResponse response = request.execute();
			// close connection in order to return a possible cached connection to the connection pool
			response.close();
		} catch (IOException e) {
			ourLog.error("Error trying to reach " + theMsg.getSubscription().getEndpointUrl());
			e.printStackTrace();
			throw new ResourceNotFoundException(e.getMessage());
		}
	}
168493
@Override
	public void registerTaskEventListener(EventListener<TaskEvent> listener, Class<? extends TaskEvent> eventType) {
		taskEventHandler.subscribe(listener, eventType);
	}
1332059
private void notifyListenersAfterRequest(ModbusRequest req) {
        synchronized (listeners) {
            for (AbstractSerialTransportListener listener : listeners) {
                listener.afterRequestRead(commPort, req);
            }
        }
    }
1321757
@Override
    public void subscribeRemoteEvent(String eventName, boolean subscribe) {
        String channelName = EventUtil.getChannelName(eventName);
        
        if (subscribe) {
            consumer.subscribe(channelName, this);
        } else {
            consumer.unsubscribe(channelName, this);
        }
    }
296796
@Override
  public void doSessionTerminationRequestEvent(ServerAuthSession appSession, SessionTermRequest str)
      throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
    logger.info("Diameter Gq AuthorizationSessionFactory :: doSessionTerminationRequestEvent :: appSession[{}], STR[{}]", appSession, str);
  }
574612
void triggerSessionRequested(Jingle initJin) {

        JingleSessionRequestListener[] jingleSessionRequestListeners;

        // Make a synchronized copy of the listenerJingles
        synchronized (this.jingleSessionRequestListeners) {
            jingleSessionRequestListeners = new JingleSessionRequestListener[this.jingleSessionRequestListeners.size()];
            this.jingleSessionRequestListeners.toArray(jingleSessionRequestListeners);
        }

        // ... and let them know of the event
        JingleSessionRequest request = new JingleSessionRequest(this, initJin);
        for (int i = 0; i < jingleSessionRequestListeners.length; i++) {
            jingleSessionRequestListeners[i].sessionRequested(request);
        }
    }
1343994
public void setEventSubscriptionsList(java.util.Collection<EventSubscription> eventSubscriptionsList) {
        if (eventSubscriptionsList == null) {
            this.eventSubscriptionsList = null;
            return;
        }

        this.eventSubscriptionsList = new com.amazonaws.internal.SdkInternalList<EventSubscription>(eventSubscriptionsList);
    }
411651
public void subscriptionRequestReceived(SubscriptionRequest sr) throws SubscriptionException {

        LOG.info("Subscriber -> (Hub), new subscription request received.", sr.getCallback());

        try {

            verifySubscriberRequestedSubscription(sr);

            if ("subscribe".equals(sr.getMode())) {
                LOG.info("Adding callback {} to the topic {}", sr.getCallback(), sr.getTopic());
                addCallbackToTopic(sr.getCallback(), sr.getTopic());
            } else if ("unsubscribe".equals(sr.getMode())) {
                LOG.info("Removing callback {} from the topic {}", sr.getCallback(), sr.getTopic());
                removeCallbackToTopic(sr.getCallback(), sr.getTopic());
            }

        } catch (Exception e) {
            throw new SubscriptionException(e);
        }

    }
77427
@Override
  public void doPushNotificationAnswerEvent(ServerShSession session, PushNotificationRequest request, PushNotificationAnswer answer)
      throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
    // TODO Auto-generated method stub
  }
1060691
public void notifySipApplicationSessionListeners(SipApplicationSessionEventType sipApplicationSessionEventType) {
		List<SipApplicationSessionListener> listeners =
			sipContext.getListeners().getSipApplicationSessionListeners();
		if(listeners.size() > 0) {
			ClassLoader oldClassLoader = java.lang.Thread.currentThread().getContextClassLoader();
			sipContext.enterSipContext();
			SipApplicationSessionEvent event = new SipApplicationSessionEvent(this.getFacade());
			if(logger.isDebugEnabled()) {
				logger.debug("notifying sip application session listeners of context " +
						key.getApplicationName() + " of following event " + sipApplicationSessionEventType);
			}
			for (SipApplicationSessionListener sipApplicationSessionListener : listeners) {
				try {
					if(logger.isDebugEnabled()) {
						logger.debug("notifying sip application session listener " + sipApplicationSessionListener.getClass().getName() + " of context " +
								key.getApplicationName() + " of following event " + sipApplicationSessionEventType);
					}
					if(SipApplicationSessionEventType.CREATION.equals(sipApplicationSessionEventType)) {
						sipApplicationSessionListener.sessionCreated(event);
					} else if (SipApplicationSessionEventType.DELETION.equals(sipApplicationSessionEventType)) {
						sipApplicationSessionListener.sessionDestroyed(event);
					} else if (SipApplicationSessionEventType.EXPIRATION.equals(sipApplicationSessionEventType)) {
						sipApplicationSessionListener.sessionExpired(event);
					} else if (SipApplicationSessionEventType.READYTOINVALIDATE.equals(sipApplicationSessionEventType)) {
						sipApplicationSessionListener.sessionReadyToInvalidate(event);
					}

				} catch (Throwable t) {
					logger.error("SipApplicationSessionListener threw exception", t);
				}
			}
			sipContext.exitSipContext(oldClassLoader);
		}
	}
1078611
@Override
  public void addUpdateListener( AsyncCallback<T> callback )
  {
    DataSubscription subscription = new DataSubscription( RTDataEvents.updated, tableName, createCallback( callback ) );
    addEventListener( subscription );
  }
121084
public void notifyProxies (DEvent event)
    {
        if (_subs == null || event.isPrivate()) {
            return;
        }

        for (Object sub : _subs) {
            try {
                if (sub != null && sub instanceof ProxySubscriber) {
                    ((ProxySubscriber)sub).eventReceived(event);
                }
            } catch (Exception e) {
                log.warning("Proxy choked during notification", "sub", sub, "event", event, e);
            }
        }
    }
255683
public int subscribe_event(final DeviceProxy deviceProxy, final String attributeName,
	            final int event, final CallBack callback, final String[] filters,
	            final boolean stateless) throws DevFailed {
        int id = 0;
        try {
            id = EventConsumerUtil.getInstance().subscribe_event(deviceProxy,
                    attributeName.toLowerCase(), event, callback, filters, stateless);
        } catch (final DevFailed e) {
            throw e;
        } catch (final Exception e) {
            e.printStackTrace();
            Except.throw_communication_failed(e.toString(), "Subscribe event on "
                + name(deviceProxy) + "/" + attributeName + " Failed !",
                "DeviceProxy.subscribe_event()");
        }
        return id;
    }
541222
public void InvokeEvent(String eventName, JSONArray args)
    {
        HubOnDataCallback subscription;
        if(mSubscriptions.containsKey(eventName))
        {
        	subscription = mSubscriptions.get(eventName);
            subscription.OnReceived(args);
        }
    }