/** Add a listener to this listener type. Any number of listeners are supported. */ public void addListener(JAMonListener listenerToAdd) { synchronized(lockObj) { // this first case is either 1) the first listener for this type. // in this case for performance reasons there is no reason to create // a compositeListener at this point, 2) a null was passed so the listener // will be nullified. Either way the listener is assigned to the variable // representing the Listenertype if (listener == null || listenerToAdd == null) listener = listenerToAdd; else // else add the listener to the composite (create the composite if necessary) listener = addCompositeListener(listenerToAdd); } }
/** * Add a listener that receives notification every time this monitors * add method is called. If null is passed all associated Listeners will * be detached. */ // Some jamon 2.4 introduced methods. Mostly listener related. public void addListener(JAMonListener listenerToAdd) { synchronized(lockObj) { // this first case is either 1) the first listener for this type. // in this case for performance reasons there is no reason to create // a compositeListener at this point, 2) a null was passed so the listener // will be nullified. Either way the listener is assigned to the variable // representing the Listenertype if (listener == null || listenerToAdd == null) listener = listenerToAdd; else // else add the listener to the composite (create the composite if necessary) listener = addCompositeListener(listenerToAdd); } }