From: David J. <d_j...@us...> - 2002-05-02 23:25:25
|
User: d_jencks Date: 02/05/02 16:25:22 Modified: src/main/org/jboss/system ServiceMBeanSupport.java Log: Made NotificationBroadcaster support a little more extensible and thread safe (merge from Branch_3_0) Revision Changes Path 1.2 +24 -8 jboss-system/src/main/org/jboss/system/ServiceMBeanSupport.java Index: ServiceMBeanSupport.java =================================================================== RCS file: /cvsroot/jboss/jboss-system/src/main/org/jboss/system/ServiceMBeanSupport.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ServiceMBeanSupport.java 24 Feb 2002 10:24:34 -0000 1.1 +++ ServiceMBeanSupport.java 2 May 2002 23:25:22 -0000 1.2 @@ -33,7 +33,7 @@ * @author <a href="mailto:Sco...@di...">Scott Stark</a> * @author <a href="mailto:an...@jb...">Andreas Schaefer</a> * @author <a href="mailto:ja...@pl...">Jason Dillon</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * * <p><b>Revisions:</b> * @@ -70,7 +70,7 @@ private int state; /** Indentifier tracker for notifications we send out. */ - private int id = 0; + private long sequenceNumber = 0; /** * Construct a <t>ServiceMBeanSupport</tt>. @@ -153,7 +153,7 @@ state = STARTING; //AS It seems that the first attribute is not needed anymore and use a long instead of a Date - sendNotification(new AttributeChangeNotification(this, id++, new Date().getTime(), getName()+" starting", "State", "java.lang.Integer", new Integer(STOPPED), new Integer(STARTING))); + sendNotification(new AttributeChangeNotification(this, getNextNotificationSequenceNumber(), new Date().getTime(), getName()+" starting", "State", "java.lang.Integer", new Integer(STOPPED), new Integer(STARTING))); log.info("Starting"); NDC.push(getName()); @@ -165,7 +165,7 @@ { state = FAILED; //AS It seems that the first attribute is not needed anymore and use a long instead of a Date - sendNotification(new AttributeChangeNotification(this, id++, new Date().getTime(), getName()+" failed", "State", "java.lang.Integer", new Integer(STARTING), new Integer(FAILED))); + sendNotification(new AttributeChangeNotification(this, getNextNotificationSequenceNumber(), new Date().getTime(), getName()+" failed", "State", "java.lang.Integer", new Integer(STARTING), new Integer(FAILED))); log.error("Starting failed", e); throw e; } @@ -176,7 +176,7 @@ state = STARTED; //AS It seems that the first attribute is not needed anymore and use a long instead of a Date - sendNotification(new AttributeChangeNotification(this, id++, new Date().getTime(), getName()+" started", "State", "java.lang.Integer", new Integer(STARTING), new Integer(STARTED))); + sendNotification(new AttributeChangeNotification(this, getNextNotificationSequenceNumber(), new Date().getTime(), getName()+" started", "State", "java.lang.Integer", new Integer(STARTING), new Integer(STARTED))); log.info("Started"); } @@ -187,7 +187,7 @@ state = STOPPING; //AS It seems that the first attribute is not needed anymore and use a long instead of a Date - sendNotification(new AttributeChangeNotification(this, id++, new Date().getTime(), getName()+" stopping", "State", "java.lang.Integer", new Integer(STARTED), new Integer(STOPPING))); + sendNotification(new AttributeChangeNotification(this, getNextNotificationSequenceNumber(), new Date().getTime(), getName()+" stopping", "State", "java.lang.Integer", new Integer(STARTED), new Integer(STOPPING))); log.info("Stopping"); NDC.push(getName()); @@ -199,7 +199,7 @@ { state = FAILED; //AS It seems that the first attribute is not needed anymore and use a long instead of a Date - sendNotification(new AttributeChangeNotification(this, id++, new Date().getTime(), getName()+" failed", "State", "java.lang.Integer", new Integer(STOPPING), new Integer(FAILED))); + sendNotification(new AttributeChangeNotification(this, getNextNotificationSequenceNumber(), new Date().getTime(), getName()+" failed", "State", "java.lang.Integer", new Integer(STOPPING), new Integer(FAILED))); log.error("Stopping failed", e); return; } @@ -210,7 +210,7 @@ state = STOPPED; //AS It seems that the first attribute is not needed anymore and use a long instead of a Date - sendNotification(new AttributeChangeNotification(this, id++, new Date().getTime(), getName()+" stopped", "State", "java.lang.Integer", new Integer(STOPPING), new Integer(STOPPED))); + sendNotification(new AttributeChangeNotification(this, getNextNotificationSequenceNumber(), new Date().getTime(), getName()+" stopped", "State", "java.lang.Integer", new Integer(STOPPING), new Integer(STOPPED))); log.info("Stopped"); } @@ -286,6 +286,20 @@ // this is presumably redundant.... // ServiceController should have called stop already. stop(); + //clean up + server = null; + serviceName = null; + } + + /** + * The <code>getNextNotificationSequenceNumber</code> method returns + * the next sequence number for use in notifications. + * + * @return a <code>long</code> value + */ + protected synchronized long getNextNotificationSequenceNumber() + { + return sequenceNumber++; } @@ -342,4 +356,6 @@ * anything specific for this state change. */ protected void destroyService() throws Exception {} + + } |