[jboss-svn-commits] JBL Code SVN: r32987 - labs/jbossesb/branches/JBESB_4_7_CP/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu May 20 12:56:10 EDT 2010
Author: kevin.conner at jboss.com
Date: 2010-05-20 12:56:09 -0400 (Thu, 20 May 2010)
New Revision: 32987
Modified:
labs/jbossesb/branches/JBESB_4_7_CP/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb/ESBMessageEventPoller.java
labs/jbossesb/branches/JBESB_4_7_CP/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb/ServiceComponent.java
Log:
Fix synchronization and ignore polling for null bean: JBESB-3325
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb/ESBMessageEventPoller.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb/ESBMessageEventPoller.java 2010-05-20 16:53:49 UTC (rev 32986)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb/ESBMessageEventPoller.java 2010-05-20 16:56:09 UTC (rev 32987)
@@ -98,9 +98,10 @@
* Set the Ems connection and grab the emsbean.
* @param connection
*/
- public void setConnection(EmsConnection connection) {
+ public boolean setConnection(EmsConnection connection) {
this.connection = connection;
- this.emsbean = connection.getBean(MESSAGE_ALERTS_BEAN);
+ this.emsbean = connection.getBean(MESSAGE_ALERTS_BEAN);
+ return (emsbean != null) ;
}
/** Return the type of events we handle
@@ -113,32 +114,30 @@
/** Return collected events
* @see org.rhq.core.pluginapi.event.EventPoller#poll()
*/
- public Set<Event> poll() {
- synchronized(emsbean) {
- if (emsbean != null) {
- try {
- EmsAttribute alertAttribute = emsbean.getAttribute(ALERTS_ATTRIBUTE);
- if (alertAttribute != null) {
- Vector<Hashtable> notifList = null;
- notifList = (Vector<Hashtable>) alertAttribute.refresh();
- for (Hashtable notifHash : notifList) {
- long timestamp = (new Long ((String) notifHash.get(NOTIFICATION_TIMESTAMP_LONG))).longValue();
-
- Event event = new Event(getEventType(),
- ((String)notifHash.get(NOTIFICATION_TYPE)),
- timestamp,
- EventSeverity.WARN,
- ((String)notifHash.get(NOTIFICATION_MESSAGE)));
- EmsOperation clear = emsbean.getOperation(CLEAR_ALERT_OPERATION);
- clear.invoke();
- events.add(event);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
+ public synchronized Set<Event> poll() {
+ if (emsbean != null) {
+ try {
+ EmsAttribute alertAttribute = emsbean.getAttribute(ALERTS_ATTRIBUTE);
+ if (alertAttribute != null) {
+ Vector<Hashtable> notifList = null;
+ notifList = (Vector<Hashtable>) alertAttribute.refresh();
+ for (Hashtable notifHash : notifList) {
+ long timestamp = (new Long ((String) notifHash.get(NOTIFICATION_TIMESTAMP_LONG))).longValue();
+
+ Event event = new Event(getEventType(),
+ ((String)notifHash.get(NOTIFICATION_TYPE)),
+ timestamp,
+ EventSeverity.WARN,
+ ((String)notifHash.get(NOTIFICATION_MESSAGE)));
+ EmsOperation clear = emsbean.getOperation(CLEAR_ALERT_OPERATION);
+ clear.invoke();
+ events.add(event);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
return events;
}
}
Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb/ServiceComponent.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb/ServiceComponent.java 2010-05-20 16:53:49 UTC (rev 32986)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/tools/jonplugin/src/main/java/org/jbosson/plugins/jbossesb/ServiceComponent.java 2010-05-20 16:56:09 UTC (rev 32987)
@@ -69,8 +69,9 @@
eventContext = context.getEventContext();
ESBMessageEventPoller ep = new ESBMessageEventPoller(ESB_MESSAGE_EVENT);
- ep.setConnection(getEmsConnection());
- eventContext.registerEventPoller(ep, 53);
+ if (ep.setConnection(getEmsConnection())) {
+ eventContext.registerEventPoller(ep, 53);
+ }
}
@Override
More information about the jboss-svn-commits
mailing list