Example usage for javax.management Notification setUserData

List of usage examples for javax.management Notification setUserData

Introduction

In this page you can find the example usage for javax.management Notification setUserData.

Prototype

public void setUserData(Object userData) 

Source Link

Document

Set the user data.

Usage

From source file:org.motrice.jmx.BasicAppManagement.java

public void serverErrorNotification(Object userData, String requestUri, String message) {
    Notification no = new Notification("HTTP500", requestUri, SEQNO++, message);
    no.setUserData(userData);
    if (publisher != null)
        publisher.sendNotification(no);//  ww  w .  j a va  2 s.co  m
}

From source file:de.stefanheintz.log.jmxservice.LoggingConfigImpl.java

private synchronized void sendNotification(NotificationType notificationType, String message) {
    Long counter = 0L;/*from  w w  w.j a va  2s  . c o  m*/
    if (!notificationTypeMap.containsKey(notificationType))
        notificationTypeMap.put(notificationType, counter);

    counter = notificationTypeMap.get(notificationType);
    notificationTypeMap.put(notificationType, Long.valueOf(counter + 1));

    Notification notification = new Notification(notificationType.toString(), this, counter);
    notification.setUserData(message);
    publisher.sendNotification(notification);
}

From source file:org.josso.agent.SSOAgentMBean.java

public void removePartnerApp(String context) {

    if (context == null) {
        logger.warn("Trying to remove 'null' context");
        return;/*from   w  w w  .j a v a  2 s.co m*/
    }
    SSOAgent a = getSSOAgent();
    a.getConfiguration().removeSSOPartnerApp(context);
    try {
        // Send a JMX notification, use parent ObjectName instance (oname).
        Notification n = new SSOAgentMBeanNotification(JOSSO_AGENT_EVENT_REMOVE_PARTNER_APP, oname, _seq++);
        n.setUserData(context);
        this.sendNotification(n);

    } catch (MBeanException e) {
        logger.warn("Can't send JMX notificatin : \n" + e.getMessage(), e);
    }
}

From source file:org.josso.agent.SSOAgentMBean.java

public void addPartnerApp(String id, String vhost, String context, String[] ignoredWebResources) {

    if (context == null) {
        logger.warn("Tryint to add 'null' context as partner app.");
        return;//from  www.ja va 2 s. c  om
    }

    if (ignoredWebResources == null) {
        ignoredWebResources = new String[0];
    }

    SSOAgent a = getSSOAgent();
    SSOAgentConfiguration cfg = a.getConfiguration();
    cfg.addSSOPartnerApp(id, vhost, context, ignoredWebResources, null);

    List papps = cfg.getSsoPartnerApps();

    for (int i = 0; i < papps.size(); i++) {
        SSOPartnerAppConfig papp = (SSOPartnerAppConfig) papps.get(i);
        if (papp.getContext().equals(context)) {

            // Send a JMX notification, use parent ObjectName instance (oname).
            Notification n = new SSOAgentMBeanNotification(JOSSO_AGENT_EVENT_ADD_PARTNER_APP, oname, _seq++);
            n.setUserData(papp);

            try {
                this.sendNotification(n);
                return;

            } catch (MBeanException e) {
                logger.warn("Can't send JMX notificatin : \n" + e.getMessage(), e);
            }
        }
    }

}

From source file:no.uis.service.ws.studinfosolr.impl.StudinfoSolrServiceImpl.java

private void sendNotification(long seqNo, Throwable error, Object... args) {
    if (this.jmxPublisher == null) {
        return;//w  w  w  .  j a  v a2 s. c  o m
    }

    StringBuilder sb = new StringBuilder();
    for (Object arg : args) {
        if (sb.length() > 0) {
            sb.append(", ");
        }
        sb.append(arg);
    }
    final String msg = sb.toString();
    Notification notification = new Notification("SolrUpdate", this, seqNo, msg);
    if (error != null) {
        notification.setUserData(errorToString(error));
        LOG.error(msg, error);
    } else {
        LOG.info(msg);
    }
    this.jmxPublisher.sendNotification(notification);
}

From source file:com.heliosapm.tsdblite.metric.AppMetric.java

/**
 * Submits a new trace for this metric//from   w w w.  ja  v  a 2 s .c  o m
 * @param trace The trace to apply
 */
public void submit(final Trace trace) {
    lastValue = trace.isDoubleType() ? trace.getDoubleValue() : trace.getLongValue();
    lastSubmission = trace.getTimestampMs();
    lastActivity = System.currentTimeMillis();
    if (hasSubscribers()) {
        final long serial = notifSerial.incrementAndGet();
        final Notification notif = new Notification(NOTIF_NEW_SUB, objectName, notifSerial.incrementAndGet(),
                lastSubmission,
                JSON.serializeToString(new SubNotif(objectName.toString(),
                        trace.isDoubleType() ? trace.getDoubleValue() : trace.getLongValue(), lastSubmission,
                        serial)));
        notif.setUserData(trace);
        sendNotification(notif);
    }
}

From source file:org.apache.geode.admin.jmx.internal.CacheServerJmxImpl.java

/**
 * Implementation handles creation of region by extracting the details from the given event object
 * and sending the {@link SystemMemberJmx#NOTIF_REGION_CREATED} notification to the connected JMX
 * Clients. Region Path is set as User Data in Notification.
 * //from   ww  w . ja va 2 s  .  c om
 * @param event event object corresponding to the creation of a region
 */
public void handleRegionCreate(SystemMemberRegionEvent event) {
    Notification notification = new Notification(NOTIF_REGION_CREATED, this.modelMBean,
            Helper.getNextNotificationSequenceNumber(), Helper.getRegionEventDetails(event));

    notification.setUserData(event.getRegionPath());

    Helper.sendNotification(this, notification);
}

From source file:org.apache.geode.admin.jmx.internal.CacheServerJmxImpl.java

/**
 * Implementation should handle loss of region by extracting the details from the given event
 * object and sending the {@link SystemMemberJmx#NOTIF_REGION_LOST} notification to the connected
 * JMX Clients. Region Path is set as User Data in Notification. Additionally, it also clears the
 * ManagedResources created for the region that is lost.
 * /*from  www.  ja  v a  2s.  c  om*/
 * @param event event object corresponding to the loss of a region
 */
public void handleRegionLoss(SystemMemberRegionEvent event) {
    SystemMemberCacheJmxImpl cacheResource = this.managedSystemMemberCache;

    if (cacheResource != null) {
        ManagedResource cleanedUp = cacheResource.cleanupRegionResources(event.getRegionPath());

        if (cleanedUp != null) {
            MBeanUtil.unregisterMBean(cleanedUp);
        }
    }

    Notification notification = new Notification(NOTIF_REGION_LOST, this.modelMBean,
            Helper.getNextNotificationSequenceNumber(), Helper.getRegionEventDetails(event));

    notification.setUserData(event.getRegionPath());

    Helper.sendNotification(this, notification);
}

From source file:com.alibaba.dragoon.patrol.spring.DragoonMethodInterceptor.java

private Notification createBeforeInvokeNotification(MethodInfo methodInfo, MethodInvocation invocation) {
    Notification notification = new Notification("method.invokeBefore",
            methodStats.getNotificationSource(methodInfo), methodStats.createNotificationSequence(),
            System.currentTimeMillis(), methodInfo.getSignature());

    List<Object> args = new ArrayList<Object>();
    for (int i = 0; i < invocation.getArguments().length; ++i) {
        Object arg = invocation.getArguments()[i];
        if (arg == null) {
            args.add(null);/*from w ww  . jav  a 2 s.com*/
        } else {
            args.add(arg.toString());
        }
    }
    notification.setUserData(args);
    return notification;
}

From source file:org.helios.netty.jmx.MetricCollector.java

/**
 * Collects metric names from participating metric providers
 * @throws JSONException thrown on any json exception 
 *///  ww w  .j av  a2 s .c  o m
protected void updateMetricNames() throws JSONException {
    Notification notif = new Notification(MetricProvider.METRIC_NAME_NOTIFICATION, OBJECT_NAME,
            tick.incrementAndGet(), System.currentTimeMillis());
    final Set<String> names = new HashSet<String>();
    final Set<String> newNames = new HashSet<String>();
    notif.setUserData(names);
    sendNotification(notif);
    for (String s : names) {
        if (metricNames.add(s)) {
            newNames.add(s);
        }
    }
    if (!newNames.isEmpty()) {
        JSONObject envelope = new JSONObject();
        envelope.put("metric-names", new JSONArray(newNames));
        SharedChannelGroup.getInstance().write(envelope);
    }
}