/*
(non-Javadoc)

@see org.restcomm.protocols.ss7.map.api.service.supplementary. MAPServiceSupplementaryListener
#onUnstructuredSSNotifyRequestIndication(org .mobicents.protocols.ss7.map.api
.service.supplementary.UnstructuredSSNotifyRequestIndication)
347856
@Override
    public void onUnstructuredSSNotifyRequest(UnstructuredSSNotifyRequest unstrNotifyInd) {
        // This error condition. Client should never receive the
        // UnstructuredSSNotifyRequestIndication
        logger.error(String.format("onUnstructuredSSNotifyRequestIndication for Dialog=%d and invokeId=%d",
                unstrNotifyInd.getMAPDialog().getLocalDialogId(), unstrNotifyInd.getInvokeId()));
    }
1000533
protected static void requestNotificationOnChange(JvmType type, Runnable listener) {
		Resource resource = type.eResource();
		if (resource instanceof TypeResource) {
			IMirror mirror = ((TypeResource) resource).getMirror();
			if (mirror instanceof IMirrorExtension) {
				if (((IMirrorExtension) mirror).isSealed())
					return;
			}
		}
		Notifier notifier = type;
		if (resource != null) {
			if (resource.getResourceSet() != null)
				notifier = resource.getResourceSet();
			else
				notifier = resource;
		}
		JvmTypeChangeDispatcher dispatcher = JvmTypeChangeDispatcher.findResourceChangeDispatcher(notifier);
		dispatcher.requestNotificationOnChange(type, listener);
	}
916694
public void notifyObserversOfRequestAdded(CachedSpiceRequest<?> request, Set<RequestListener<?>> requestListeners) {
        RequestProcessingContext requestProcessingContext = new RequestProcessingContext();
        requestProcessingContext.setExecutionThread(Thread.currentThread());
        requestProcessingContext.setRequestListeners(requestListeners);
        post(new RequestAddedNotifier(request, spiceServiceListenerList, requestProcessingContext));
    }
1344866
@Override
    public void step(SimState arg0) {
        logger.finest("Notifying each element of the notifable element list...");
        for(Notifable n: NotificationManager.notifables){
            NotificationManager.addNotification(n);
        }
    }
99531
@Override
    public void notifyStandBy() {
        synchronized (qSync) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "notifyStandBy called with qStatus: " + qStatus);
            }
            if (qStatus == Q_STATUS.BYPASSED) {
                // no other writes waiting, so no queue thread in flight.  Set the state for more caller thread processing
                qStatus = Q_STATUS.NOT_IN_USE;
            } else if (qStatus == Q_STATUS.STAND_BY) {
                // Requests have been put on the Queue while we were writing, The Queue thread waiting to service them can start now
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "notifyStandBy doing notify");
                }
                qSync.notify();
            }
        }
    }
775188
public void queueNotification(
            final Collection<ClientInterfaceHandleManager> connections,
            final Supplier<DeferredSerialization> notification,
            final Predicate<ClientInterfaceHandleManager> wantsNotificationPredicate) {
        m_submissionQueue.offer(new Runnable() {
            @Override
            public void run() {
                for (ClientInterfaceHandleManager cihm : connections) {
                    if (!wantsNotificationPredicate.apply(cihm)) continue;
                    final Connection c = cihm.connection;

                    /*
                     * To avoid extra allocations and promotion we initially store a single event
                     * as just the event. Once we have two or more events we create a linked list
                     * and walk the list to dedupe events by identity
                     */
                    Object pendingNotifications = m_clientsPendingNotification.get(c);
                    try {
                        if (pendingNotifications == null) {
                            m_clientsPendingNotification.put(c, notification);
                        } else if (pendingNotifications instanceof Supplier) {
                            //Identity duplicate check
                            if (pendingNotifications == notification) return;
                            //Convert to a two node linked list
                            @SuppressWarnings("unchecked")
                            Node n1 = new Node((Supplier<DeferredSerialization>)pendingNotifications, null);
                            n1 = m_cachedNodes.get(n1, n1);
                            Node n2 = new Node(notification, n1);
                            n2 = m_cachedNodes.get(n2, n2);
                            m_clientsPendingNotification.put(c,  n2);
                        } else {
                            //Walk the list and check if the notification is a duplicate
                            Node head = (Node)pendingNotifications;
                            boolean dup = false;
                            while (head != null) {
                                if (head.notification == notification) {
                                    dup = true;
                                    break;
                                }
                                head = head.next;
                            }
                            //If it's a dupe, no new work
                            if (dup) continue;
                            //Otherwise replace the head of the list which is the value in the map
                            Node replacement = new Node(notification, (Node)pendingNotifications);
                            replacement = m_cachedNodes.get(replacement, replacement);
                            m_clientsPendingNotification.put(c, replacement);
                        }
                    } catch (ExecutionException e) {
                        VoltDB.crashLocalVoltDB(
                                "Unexpected exception pushing client notifications",
                                true,
                                Throwables.getRootCause(e));
                    }
                }
            }
        });
    }
130314
public static void notifyRequestListener(Http2SourceHandler http2SourceHandler, HttpCarbonMessage httpRequestMsg,
                                             int streamId) {
        if (http2SourceHandler.getServerConnectorFuture() != null) {
            try {
                ServerConnectorFuture outboundRespFuture = httpRequestMsg.getHttpResponseFuture();
                outboundRespFuture.setHttpConnectorListener(new Http2OutboundRespListener(
                        http2SourceHandler.getServerChannelInitializer(), httpRequestMsg,
                        http2SourceHandler.getChannelHandlerContext(), http2SourceHandler.getConnection(),
                        http2SourceHandler.getEncoder(), streamId, http2SourceHandler.getServerName(),
                        http2SourceHandler.getRemoteAddress()));
                http2SourceHandler.getServerConnectorFuture().notifyHttpListener(httpRequestMsg);
            } catch (Exception e) {
                LOG.error("Error while notifying listeners", e);
            }
        } else {
            LOG.error("Cannot find registered listener to forward the message");
        }
    }
968017
public void addClientNotificationListener(RESTRequest request, NotificationRegistration notificationRegistration, JSONConverter converter) {
        String objectNameStr = notificationRegistration.objectName.getCanonicalName();

        NotificationTargetInformation nti = toNotificationTargetInformation(request, objectNameStr);

        // Get the listener
        ClientNotificationListener listener = listeners.get(nti);
        if (listener == null) {
            listener = new ClientNotificationListener(this);
            ClientNotificationListener mapListener = listeners.putIfAbsent(nti, listener);

            if (mapListener != null) {
                listener = mapListener;
            }
        }

        // Grab the wrapper filter which will be registered in the MBeanServer
        NotificationFilter filter = listener.getClientWrapperFilter();

        // Check whether the producer of the notification is local or remote.
        if (nti.getRoutingInformation() == null) {
            // Add the notification in the MBeanServer        
            MBeanServerHelper.addClientNotification(notificationRegistration.objectName,
                                                    listener,
                                                    filter,
                                                    null,
                                                    converter);
        } else {
            // Add the notification listener to the Target-Client Manager through EventAdmin
            MBeanRoutedNotificationHelper helper = MBeanRoutedNotificationHelper.getMBeanRoutedNotificationHelper();
            helper.addRoutedNotificationListener(nti, listener, converter);
        }

        // Add the filters to the listener
        listener.addClientNotification(notificationRegistration.filters);
    }
961664
public void setConnectionNotificationIds(java.util.Collection<String> connectionNotificationIds) {
        if (connectionNotificationIds == null) {
            this.connectionNotificationIds = null;
            return;
        }

        this.connectionNotificationIds = new com.amazonaws.internal.SdkInternalList<String>(connectionNotificationIds);
    }
1355344
public void notifyObserversOfRequestProcessed(CachedSpiceRequest<?> request, Set<RequestListener<?>> requestListeners) {
        RequestProcessingContext requestProcessingContext = new RequestProcessingContext();
        requestProcessingContext.setExecutionThread(Thread.currentThread());
        requestProcessingContext.setRequestListeners(requestListeners);
        post(new RequestProcessedNotifier(request, spiceServiceListenerList, requestProcessingContext));
    }
700091
protected void updateNotify (long sequence) {

		IServiceReference[] refs = null;
		try {
			if(aggregator != null && aggregator.getPlatformServices() != null){
				refs = aggregator.getPlatformServices().getServiceReferences(IOptionsListener.class.getName(),"(name=" + registrationName + ")");	//$NON-NLS-1$ //$NON-NLS-2$
				if (refs != null) {
					for (IServiceReference ref : refs) {
						IOptionsListener listener = (IOptionsListener)aggregator.getPlatformServices().getService(ref);
						if (listener != null) {
							try {
								listener.optionsUpdated(this, sequence);
							} catch (Throwable ignore) {
							} finally {
								aggregator.getPlatformServices().ungetService(ref);
							}
						}
					}
				}
			}
		} catch (PlatformServicesException e) {
			if (log.isLoggable(Level.SEVERE)) {
				log.log(Level.SEVERE, e.getMessage(), e);
			}
		}
	}
928287
@Override
  public void doPushNotificationRequestEvent(ClientShSession session, PushNotificationRequest request)
      throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
    // TODO Auto-generated method stub
  }
274436
@Override
    public void handleNotification(Notification notification, Object handback) {
        if(notification instanceof MBeanServerNotification) {
            MBeanServerNotification mbeanNotification = (MBeanServerNotification) notification;
            if(mbeanNotification.getType().equals("JMX.mbean.registered")) {
                jmxTree = null;
               
               registerAsNotificationListener(mbeanNotification.getMBeanName());
                
            } else if(mbeanNotification.getType().equals("JMX.mbean.unregistered")) {
                jmxTree = null;
            }
        } 
        for (NotificationListener listener : listeners) {
            listener.handleNotification(notification, handback);
        }

    }
611952
public void push_structured_event(org.omg.CosNotification.StructuredEvent notification) {

        String domainName = notification.header.fixed_header.event_type.domain_name;
        String eventType = notification.header.fixed_header.event_name;
        try {
            //	Check if Heartbeat event
            if (eventType.equals("heartbeat")) {
                push_structured_event_heartbeat(domainName);
                return;
            }
            //	Else check if event is registered and get its CB struct
            String eventName = domainName + "." + eventType;
            EventCallBackStruct callBackStruct = getEventCallBackStruct(eventName);
            if (callBackStruct!=null) {
                CallBack callback = callBackStruct.callback;
                DeviceAttribute attr_value = null;
                AttributeInfoEx attr_config = null;
                AttDataReady data_ready = null;
                DevError[] dev_err_list = null;

                //	Extract CORBA object to check What kind (Value or config)
                java.lang.Object obj = extractAttributeObject(notification);
                if (obj instanceof AttributeInfoEx)
                    attr_config = (AttributeInfoEx) obj;
                else if (obj instanceof AttDataReady)
                    data_ready = (AttDataReady) obj;
                else if (obj instanceof DeviceAttribute)
                    attr_value = (DeviceAttribute) obj;
                else if (obj instanceof DevError[])
                    dev_err_list = (DevError[]) obj;

                //	And build event data
                EventData event_data =
                        new EventData(callBackStruct.device,
                                domainName, eventType,
                                callBackStruct.event_type, EventData.NOTIFD_EVENT,
                                attr_value, null, attr_config, data_ready, null, dev_err_list);


                if (callBackStruct.use_ev_queue) {
                    EventQueue ev_queue = callBackStruct.device.getEventQueue();
                    ev_queue.insert_event(event_data);
                } else if (callback != null)
                    callback.push_event(event_data);
            }
            else
                System.err.println(eventName + " event not found");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
99419
@Override
    public void onProcessUnstructuredSSResponse(ProcessUnstructuredSSResponse procUnstrResInd) {
        if (logger.isDebugEnabled()) {
            logger.debug(String.format("Rx ProcessUnstructuredSSResponseIndication.  USSD String=%s",
                    procUnstrResInd.getUSSDString()));
        }

    }
118764
@Override
    public Object onRequest(Object request, Map<String,String> headers) {
        if (headers.containsKey(Listener.METAINFO_HTTP_METHOD)) {
            Tracing tracing = TraceHelper.getTracing("mdw-service");
            HttpTracing httpTracing = HttpTracing.create(tracing);
            handler = HttpServerHandler.create(httpTracing, new ServerAdapter());
            extractor = httpTracing.tracing().propagation().extractor(ServerAdapter.ServerRequest::getHeader);
            span = handler.handleReceive(extractor, new ServerAdapter.ServerRequest(headers));
            scope = httpTracing.tracing().tracer().withSpanInScope(span);
        }
        return null;
    }
907298
public void onUpdateNotification(NotificationView view, View contentView, NotificationEntry entry, int layoutId) {
        if (DBG) Log.v(TAG, "onUpdateNotification - " + entry.ID);

        final Drawable icon = entry.iconDrawable;
        final CharSequence title = entry.title;
        final CharSequence text = entry.text;
        final CharSequence when = entry.showWhen ? entry.whenFormatted : null;

        ChildViewManager mgr = view.getChildViewManager();

        mgr.setImageDrawable(ICON, icon, false);
        mgr.setText(TITLE, title, false);
        mgr.setText(TEXT, text, false);
        mgr.setText(WHEN, when, false);
    }