List of usage examples for javax.management Notification Notification
public Notification(String type, Object source, long sequenceNumber, long timeStamp)
From source file:de.iew.framework.mbean.TestMB.java
@ManagedAttribute(description = "The Name Attribute", currencyTimeLimit = 20, defaultValue = "bar", persistPolicy = "OnUpdate") public void setTestValue(String testValue) { this.testValue = testValue; this.notificationPublisher .sendNotification(new Notification("TestValueMessage", this, 0, "test Value changed")); }
From source file:org.apache.camel.management.JmxNotificationEventNotifier.java
public void notify(EventObject event) throws Exception { if (notificationBroadcaster != null) { // its recommended to send light weight events and we don't want to have the entire Exchange/CamelContext etc // serialized as these are the typical source of the EventObject. So we use our own source which is just // a human readable name, which can be configured. String type = event.getClass().getSimpleName(); String message = event.toString(); Notification notification = new Notification(type, source, counter.getAndIncrement(), message); if (LOG.isTraceEnabled()) { LOG.trace("Broadcasting JMX notification: " + notification); }/*from ww w . ja v a 2 s.c o m*/ notificationBroadcaster.sendNotification(notification); } }
From source file:org.springframework.batch.sample.jmx.JobExecutionNotificationPublisher.java
/** * Publish the provided message to an external listener if there is one. * /*from www .j a va 2s .c o m*/ * @param message the message to publish */ private void publish(String message) { if (notificationPublisher != null) { Notification notification = new Notification("JobExecutionApplicationEvent", this, notificationCount++, message); /* * We can't create a notification with a null source, but we can set * it to null after creation(!). We want it to be null so that * Spring will replace it automatically with the ObjectName (in * ModelMBeanNotificationPublisher). */ notification.setSource(null); notificationPublisher.sendNotification(notification); } }
From source file:kr.okplace.job.support.JobExecutionNotificationPublisher.java
/** * Publish the provided message to an external listener if there is one. * /*from w ww . j av a2 s .co m*/ * @param message the message to publish */ private void publish(String message) { if (notificationPublisher != null) { Notification notification = new Notification("JobExecutionApplicationEvent", this, notificationCount++, message); /* * We can't create a notification with a null source, but we can set * it to null after creation(!). We want it to be null so that * Spring will replace it automatically with the ObjectName (in * ModelMBeanNotificationPublisher). */ notification.setSource(null); notificationPublisher.sendNotification(notification); } }
From source file:org.springframework.batch.admin.jmx.StepExecutionServiceLevelMonitor.java
public void invoke(ProceedingJoinPoint joinPoint, final StepExecution stepExecution, Step step) throws Throwable { final AtomicBoolean finished = new AtomicBoolean(false); final StopWatch timer = new StopWatch(stepExecution.getStepName() + ":execution"); try {/* w w w . j a v a 2 s . c o m*/ if (timeout > 0) { if (notificationPublisher != null) { Notification notification = new Notification("INFO", this, sequence++, "Starting:" + stepExecution); notificationPublisher.sendNotification(notification); } timer.start("StepExecution.Id:" + stepExecution.getId()); final long threshold = (long) (timeout * (1 - warningMargin)); Date warningTime = new Date(System.currentTimeMillis() + threshold); logger.debug("Scheduling warning after (ms) " + threshold); taskScheduler.schedule(new Runnable() { public void run() { if (!finished.get()) { logger.debug("Sending warning (step not complete after " + threshold + " ms): " + stepExecution); if (notificationPublisher != null) { Notification notification = new Notification("WARN", StepExecutionServiceLevelMonitor.this, sequence++, "Warning:" + stepExecution); notificationPublisher.sendNotification(notification); } } else { logger.debug("No warning necessary for " + stepExecution); } } }, warningTime); } joinPoint.proceed(); } finally { finished.set(true); if (timeout > 0) { timer.stop(); Executors.newSingleThreadScheduledExecutor().shutdown(); if (timer.getLastTaskTimeMillis() > timeout) { overruns++; logger.debug("Notifying overrun " + stepExecution); if (notificationPublisher != null) { Notification notification = new Notification("ERROR", this, sequence++, "Overrun:" + stepExecution); notificationPublisher.sendNotification(notification); } } } } }
From source file:com.paxxis.cornerstone.messaging.service.ServiceBusManager.java
public void notifyConnectionFailed() { _publisher.sendNotification(new Notification("ServiceBusConnector.Connection", "ServiceBusConnector", ++_seqNum, "Bus Connection Failed")); }
From source file:com.paxxis.cornerstone.messaging.service.ServiceBusManager.java
/** * Publishes a notification message containing the current connection status. *//*from w w w. java 2s.c om*/ public void notifyConnectionStatusChange() { _publisher.sendNotification(new Notification("ServiceBusConnector.Status", "ServiceBusConnector", ++_seqNum, _collaborator.getConnectionStatus())); }
From source file:org.sakaiproject.search.mbeans.SearchServiceManagement.java
/** * /*from w ww . j a va 2s .c o m*/ */ public void init() { try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); final ObjectName searchServiceON = new ObjectName(MBEAN_COMPONENT_BASE + name); mbs.registerMBean(this, searchServiceON); indexStorageProvider.addIndexListener(new IndexListener() { public void doIndexReaderClose(IndexReader oldMultiReader) throws IOException { sendNotification(new Notification("index-reader-close", searchServiceON, notificationNo++, "Closed oldMultiReader")); } public void doIndexReaderOpen(IndexReader newMultiReader) { sendNotification(new Notification("index-reader-open", searchServiceON, notificationNo++, "Opened newMultiReader")); } public void doIndexSearcherClose(IndexSearcher indexSearcher) throws IOException { sendNotification(new Notification("index-searcher-close", searchServiceON, notificationNo++, "Closed " + indexSearcher.toString())); } public void doIndexSearcherOpen(IndexSearcher indexSearcher) { sendNotification(new Notification("index-searcher-open", searchServiceON, notificationNo++, "Opened " + indexSearcher.toString())); } }); indexWorker.addIndexWorkerDocumentListener(new IndexWorkerDocumentListener() { public void indexDocumentEnd(IndexWorker worker, String ref) { sendNotification(new Notification("index-document-start", searchServiceON, notificationNo++, "Doc Ref " + ref)); } public void indexDocumentStart(IndexWorker worker, String ref) { sendNotification(new Notification("index-document-end", searchServiceON, notificationNo++, "Doc Ref " + ref)); } }); indexWorker.addIndexWorkerListener(new IndexWorkerListener() { public void indexWorkerEnd(IndexWorker worker) { sendNotification(new Notification("index-woker-start", searchServiceON, notificationNo++, "Worker " + worker)); } public void indexWorkerStart(IndexWorker worker) { sendNotification(new Notification("index-woker-end", searchServiceON, notificationNo++, "Worker " + worker)); } }); } catch (Exception ex) { log.warn("Failed to register mbean for search service ", ex); } }
From source file:com.googlecode.arit.jmx.LeakDetector.java
private void runDetection() { Report report = reportGenerator.generateReport(false, false); Report previousReport = lastReport.getAndSet(report); if (previousReport != null) { Map<Integer, Module> reportedModules = new HashMap<Integer, Module>(); for (Module module : previousReport.getRootModules()) { if (module.isStopped()) { reportedModules.put(module.getId(), module); }//from w w w . jav a2 s . c o m } for (Module module : report.getRootModules()) { if (module.isStopped()) { if (reportedModules.remove(module.getId()) == null) { if (log.isWarnEnabled()) { StringBuilder message = new StringBuilder(); message.append("Leak detected:\n"); dumpModule(module, message, 0); log.warn(message.toString()); } notificationPublisher .sendNotification(new Notification(LEAK_DETECTED, this, notificationSequence++, "Resource leak detected in application " + module.getName())); } } } if (log.isWarnEnabled()) { for (Module module : reportedModules.values()) { log.warn("The resource leak previously reported for application " + module.getName() + " (" + module.getId() + ") is now gone"); } } } }
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);/*from w w w.j a va 2s. c o m*/ if (publisher != null) publisher.sendNotification(no); }