1 26 27 package org.objectweb.alarm.beans; 28 29 import javax.ejb.EJBException ; 30 import javax.ejb.MessageDrivenBean ; 31 import javax.ejb.MessageDrivenContext ; 32 import javax.jms.JMSException ; 33 import javax.jms.MapMessage ; 34 import javax.jms.Message ; 35 import javax.jms.MessageListener ; 36 37 40 public class AlarmListenerBean implements MessageDrivenBean , MessageListener { 41 42 45 private static transient AlarmManager alarmManager = null; 46 47 50 public AlarmListenerBean() { 51 } 52 53 61 62 public void setMessageDrivenContext(MessageDrivenContext ctx) { 63 } 64 65 73 public void ejbRemove() throws EJBException { 74 } 75 76 81 public void ejbCreate() { 82 alarmManager = AlarmManager.getInstance(); 84 85 } 86 87 92 public void onMessage(Message message) { 93 94 int sev = 0; 95 String from = null; 96 String reason = null; 97 98 MapMessage msg = (MapMessage ) message; 100 try { 101 sev = msg.getInt("Severity"); 102 from = msg.getString("From"); 103 reason = msg.getString("Reason"); 104 } catch (JMSException e) { 105 Debug.logError("AlarmListenerBean exception:" + e); 106 } 107 alarmManager.alarm(sev, from, reason); 109 110 } 111 } | Popular Tags |