dev@glassfish.java.net

need mini review (Re: help listening for config changes)

From: Bobby Bissett <bobby.bissett_at_oracle.com>
Date: Tue, 10 Aug 2010 15:40:23 -0400

Thanks all. Good to know I can manually register the listener and have
it just implement the one method. So now I have a question about the
method. The class is listening to changes on a cluster object to know
when instances have been added or removed (this is for the asadmin get-
health command). I don't need to do anything special, just find out
that instances are added/deleted. My problem is that I don't know how
to construct the UnprocessedChangeEvents object to return.

Can I just return null like this? The JavaDoc doesn't say.

     @Override
     // lots of spacing added for email-readability
     public UnprocessedChangeEvents changed(PropertyChangeEvent[]
events) {

         Object oldVal;
         Object newVal;

         for (PropertyChangeEvent event : events) {

             oldVal = event.getOldValue();
             newVal = event.getNewValue();

             if (oldVal instanceof ServerRef && newVal == null) {
                 ServerRef instance = (ServerRef) oldVal;
                 // delete instance.getRef() from health table

             } else if (newVal instanceof ServerRef && oldVal == null) {
                 ServerRef instance = (ServerRef) newVal;
                 // add instance.getRef() from health table

             }
         }
         return null; // does this make the server secretly mad at me?
     }

Thanks,
Bobby