Issues a notification that will result in a call to {@link
BureauReceiver#destroyAgent} on a client.
500527
public static void destroyAgent (
        ClientObject target, int arg1)
    {
        sendNotification(
            target, BureauDecoder.RECEIVER_CODE, BureauDecoder.DESTROY_AGENT,
            new Object[] { Integer.valueOf(arg1) });
    }
1167353
@Override
    public void destroy() throws Exception {
        final boolean trace = TraceComponent.isAnyTracingEnabled();
        if (trace && tc.isEntryEnabled())
            Tr.entry(this, tc, "destroy", id);

        tracker.close();

        StringBuilder filter = new StringBuilder(FilterUtils.createPropertyFilter(AbstractConnectionFactoryService.ID, id));
        filter.insert(filter.length() - 1, '*');

        builder.removeExistingConfigurations(filter.toString());

        if (trace && tc.isEntryEnabled())
            Tr.exit(this, tc, "destroy");
    }
409332
@Override
    public Future<Void> destroy(final Channel channel, final Promise<Void> promise) {
        channel.close().addListener(new PromiseNotifier<>(promise));
        return promise;
    }
1006627
public synchronized void remoteClientRegistrations(RESTRequest request) {
        Iterator<Entry<NotificationTargetInformation, ClientNotificationListener>> clientListeners = listeners.entrySet().iterator();

        try {
            while (clientListeners.hasNext()) {
                Entry<NotificationTargetInformation, ClientNotificationListener> clientListener = clientListeners.next();
                NotificationTargetInformation nti = clientListener.getKey();
                ClientNotificationListener listener = clientListener.getValue();

                // Check whether the producer of the notification is local or remote.
                if (nti.getRoutingInformation() == null) {
                    // Remove the notification from the MBeanServer
                    ObjectName objName = RESTHelper.objectNameConverter(nti.getNameAsString(), false, null);

                    if (MBeanServerHelper.isRegistered(objName)) {
                        try {
                            MBeanServerHelper.removeClientNotification(objName, listener);
                        } catch (RESTHandlerJsonException exception) {
                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                Tr.debug(tc, "Received exception while cleaning up: " + exception);
                            }
                        }
                    }
                    else {
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "The MBean " + objName + " is not registered with the MBean server.");
                        }
                    }
                } else {
                    // Remove the notification listener from the Target-Client Manager through EventAdmin
                    MBeanRoutedNotificationHelper helper = MBeanRoutedNotificationHelper.getMBeanRoutedNotificationHelper();
                    helper.removeRoutedNotificationListener(nti, listener);
                }
            }
        } finally {
            //Clear the map
            listeners.clear();
        }
    }
925569
@SuppressWarnings({"checkstyle:npathcomplexity"})
	protected void fireAgentDestroyed(Agent agent) {
		final ListenerCollection<SpawnServiceListener> list;
		synchronized (getAgentLifecycleListenerMutex()) {
			list = this.agentLifecycleListeners.get(agent.getID());
		}
		final SpawnServiceListener[] ilisteners;
		if (list != null) {
			ilisteners = list.getListeners(SpawnServiceListener.class);
		} else {
			ilisteners = null;
		}
		final SpawnServiceListener[] ilisteners2 = this.globalListeners.getListeners(SpawnServiceListener.class);
		// Retrieve the agent's contexts
		final List<Pair<AgentContext, Address>> contextRegistrations = new ArrayList<>();
		try {
			final SynchronizedIterable<AgentContext> allContexts = BuiltinCapacityUtil.getContextsOf(agent);
			synchronized (allContexts.mutex()) {
				for (final AgentContext context : allContexts) {
					final EventSpace defSpace = context.getDefaultSpace();
					final Address address = defSpace.getAddress(agent.getID());
					contextRegistrations.add(Pair.of(context, address));
				}
			}
		} catch (RuntimeException e) {
			throw e;
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		// Local agent and framework destruction
		if (ilisteners != null) {
			for (final SpawnServiceListener l : ilisteners) {
				l.agentDestroy(agent);
			}
		}
		for (final SpawnServiceListener l : ilisteners2) {
			l.agentDestroy(agent);
		}
		// Fire AgentKilled into the associated contexts
		try {
			final UUID killedAgentId = agent.getID();
			final Scope<Address> scope = address -> {
				final UUID receiver = address.getUUID();
				return !receiver.equals(killedAgentId);
			};
			final String killedAgentType = agent.getClass().getName();
			for (final Pair<AgentContext, Address> registration : contextRegistrations) {
				final EventSpace defSpace = registration.getKey().getDefaultSpace();
				defSpace.emit(
						// No need to give an event source because it is explicitly set below.
						null,
						new AgentKilled(
								registration.getValue(), killedAgentId, killedAgentType),
						scope);
			}
		} catch (RuntimeException e) {
			throw e;
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
388540
protected void dispatchEvent (int remoteOid, DObject target, DEvent event)
    {
        try {
            // apply the event to the object
            boolean notify = event.applyToObject(target);

            // if this is an object destroyed event, we need to remove the object from our table
            if (event instanceof ObjectDestroyedEvent) {
//                 Log.info("Pitching destroyed object [oid=" + remoteOid +
//                          ", class=" + StringUtil.shortClassName(target) + "].");
                _ocache.remove(remoteOid);
            }

            // have the object pass this event on to its listeners
            if (notify) {
                target.notifyListeners(event);
            }

        } catch (Exception e) {
            log.warning("Failure processing event", "event", event, "target", target, e);
        }
    }
1341909
protected void handleInvocationNotification (int receiverId, int methodId, Object[] args)
    {
        // look up the decoder registered for this receiver
        InvocationDecoder decoder = _receivers.get(receiverId);
        if (decoder == null) {
            log.warning("Received notification for which we have no registered receiver",
                        "recvId", receiverId, "methodId", methodId, "args", args);
            return;
        }

//         log.info("Dispatching invocation notification", "receiver", decoder.receiver,
//                  "methodId", methodId, "args", args);

        try {
            decoder.dispatchNotification(methodId, args);
        } catch (Throwable t) {
            log.warning("Invocation notification receiver choked", "receiver", decoder.receiver,
                        "methId", methodId, "args", args, t);
        }
    }
914519
static void terminateClient( IMessagingClient client, String errorMessage, Logger logger ) {

		try {
			logger.fine( "The reconfigurable client is requesting its internal connection to be closed." );
			if( client != null )
				client.closeConnection();

		} catch( Exception e ) {
			logger.warning( errorMessage + " " + e.getMessage());
			Utils.logException( logger, e );

		} finally {
			// "unregisterService" was not merged with "closeConnection"
			// on purpose. What is specific to JMX is restricted to this class
			// and this bundle. Sub-classes may use "closeConnection" without
			// any side effect on the JMX part.
			if( client instanceof JmxWrapperForMessagingClient )
				((JmxWrapperForMessagingClient) client).unregisterService();
		}
	}
1276771
private void notifyListeners(IMessagingClientFactory factory, boolean isAdded) {

		for (MessagingClientFactoryListener listener : this.listeners) {
			try {
				if (isAdded)
					listener.addMessagingClientFactory(factory);
				else
					listener.removeMessagingClientFactory(factory);

			} catch (Throwable t) {
				// Log the exception, but *do not* interrupt the notification of the other listeners.
				this.logger.warning("Messaging client factory listener has thrown an exception: " + listener);
				Utils.logException(this.logger, new RuntimeException(t));
			}
		}
	}
144976
def do_notification_delete(mc, args):
    ''''''
    fields = {}
    fields['notification_id'] = args.id
    try:
        mc.notifications.delete(**fields)
    except (osc_exc.ClientException, k_exc.HttpError) as he:
        raise osc_exc.CommandError('%s\n%s' % (he.message, he.details))
    else:
        print('Successfully deleted notification')
543259
public void notifyEnd(String projectName, String projectVersion, String category, long duration) {
		try {
			if (isStarted()) {
				JSONObject endNotification = new JSONObject().
					put("project", new JSONObject().
						put("name", projectName).
						put("version", projectVersion)
					).
					put("category", category).
					put("duration", duration);
				
				socket.emit("run:end", endNotification);
			}
			else {
				LOGGER.warn("Minirox is not available to send the end notification");
			}
		}
		catch (Exception e) {
			LOGGER.info("Unable to send the end notification to MINI ROX. Cause: {}", e.getMessage());
			
			if (LOGGER.isDebugEnabled()) {
				LOGGER.debug("Exception: ", e);
			}
		}
	}
1284161
private void sendClosingSignal() {
        URL clientURL = null;
        HttpsURLConnection connection = null;
        try {
            // Get the appropriate URL to delete notification client
            if (serverConnection.serverVersion >= 4) {
                //V4+ clients use /{clientID} to delete the notification client
                clientURL = getNotificationClientURL();
            } else {
                //Pre-V4 clients use /{clientID}/inbox to delete the notification client
                clientURL = getInboxURL();
            }

            if (logger.isLoggable(Level.FINEST)) {
                logger.logp(Level.FINEST,
                            logger.getName(),
                            "sendClosingSignal",
                            "Making a call to delete inbox [" + clientURL + "] from ["
                                            + RESTClientMessagesUtil.getObjID(this) + "]");
            }
            // Get connection to server
            connection = serverConnection.getConnection(clientURL, HttpMethod.DELETE, true);
            connection.setReadTimeout(serverConnection.getConnector().getReadTimeout());

            // Check response code from server
            int responseCode = 0;
            try {
                responseCode = connection.getResponseCode();
            } catch (ConnectException ce) {
                logger.logp(Level.FINE, logger.getName(), "sendClosingSignal", ce.getMessage(), ce);
            }

            if (logger.isLoggable(Level.FINEST)) {
                logger.logp(Level.FINEST, logger.getName(), "sendClosingSignal", "Response code: " + responseCode);
            }

        } catch (IOException io) {
            logger.logp(Level.FINE, logger.getName(), "sendClosingSignal", io.getMessage(), io);
        }
    }
1334979
public void fireRemoveNotification (Iterator<RegistryListener<K, V>> listeners, K removeKey, V removeValue) {
        while ( listeners.hasNext() ) {
            listeners.next().onRemoveEntry(removeKey, removeValue);
        }
    }
1064310
public void stop() {

		this.logger.info( "Agent '" + getAgentId() + "' is about to be stopped." );

		// Stop the timer
		if( this.heartBeatTimer != null ) {
			this.heartBeatTimer.cancel();
			this.heartBeatTimer = null;
		}

		// Prevent NPE for successive calls to #stop()
		if( this.messagingClient == null )
			return;

		// Send a last message to the DM
		try {
			if( this.messagingClient.isConnected()) {
				this.messagingClient.sendMessageToTheDm( new MsgNotifMachineDown( this.applicationName, this.scopedInstancePath ));
				this.logger.fine( "Agent " + getAgentId() + " notified the DM it was about to stop." );
			}

		} catch( IOException e ) {
			this.logger.warning( e.getMessage());
			Utils.logException( this.logger, e );
		}

		// Close the connection
		try {
			this.messagingClient.getMessageProcessor().stopProcessor();
			this.messagingClient.getMessageProcessor().interrupt();
			this.messagingClient.closeConnection();

		} catch( IOException e ) {
			this.logger.warning( e.getMessage());
			Utils.logException( this.logger, e );
		}

		this.logger.info( "Agent '" + getAgentId() + "' was stopped." );
	}
891556
public void removeNotificationHandler(String serviceName, NotificationHandler handler){

        ServiceInstanceUtils.validateServiceName(serviceName);
        if (handler == null) {
            throw new ServiceException(ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR,
                    ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR.getMessageTemplate(),
                    "NotificationHandler");
        }
  
        synchronized(notificationHandlers){
            if(notificationHandlers.containsKey(serviceName)){
                List<NotificationHandler> list = notificationHandlers.get(serviceName);
                if(list.contains(handler)){
                    list.remove(handler);
                }
                if(list.isEmpty()){
                    notificationHandlers.remove(serviceName);
                }
            }
        }
    }
1163812
public static void sendNotification (
        ClientObject target, String receiverCode, int methodId, Object[] args)
    {
        sendNotification(target, receiverCode, methodId, args, Transport.DEFAULT);
    }
1042857
protected void physicalCloseNotification() {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "physicalCloseNotification");
      synchronized(connectionClosedLock) {
         connectionClosed = true;
      }
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "physicalCloseNotification");
   }