All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jmonit.events.DefaultMonitoringEventBus Maven / Gradle / Ivy

Go to download

jMonit is a monitoring toolkit for java application. It provides a simple API to instrument the application, and an extensible infrastructure to gather monitored datas and build monitoring reports. On JEE applications, it provides a web UI out of the box for monitoring and tweaking the application.

The newest version!
/*
 ~ Copyright 2006-2007 Nicolas De Loof.
 ~
 ~ Licensed under the Apache License, Version 2.0 (the "License");
 ~ you may not use this file except in compliance with the License.
 ~ You may obtain a copy of the License at
 ~
 ~      http://www.apache.org/licenses/LICENSE-2.0
 ~
 ~ Unless required by applicable law or agreed to in writing, software
 ~ distributed under the License is distributed on an "AS IS" BASIS,
 ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ~ See the License for the specific language governing permissions and
 ~ limitations under the License.
 */
package org.jmonit.events;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * A synchronous implementation of the MonitoringEventBus.
 * 

* "Synchronous" means the event is dispatched to and consumed by all listeners * before the emitter can resume processing. * * @author Nicolas De Loof */ public class DefaultMonitoringEventBus implements MonitoringEventBus { /** * Registered listeners */ private List listeners = new CopyOnWriteArrayList(); /** * {@inheritDoc} * * @see org.jmonit.events.MonitoringEventBus#addListener(org.jmonit.events.MonitoringEventListener) */ public void addListener( final MonitoringEventListener listener ) { if ( listener != null ) { listeners.add( listener ); } } /** * {@inheritDoc} * * @see org.jmonit.events.MonitoringEventBus#removeListener(MonitoringEventListener) */ public void removeListener( final MonitoringEventListener listener ) { listeners.remove( listener ); } /** * {@inheritDoc} * * @see org.jmonit.events.MonitoringEventBus#hasListener(MonitoringEventListener) */ public boolean hasListener( final MonitoringEventListener listener ) { return listeners.contains( listener ); } /** * {@inheritDoc} * * @see org.jmonit.events.MonitoringEventBus#fireMonitoringEvent(org.jmonit.events.MonitoringEvent) */ public void fireMonitoringEvent( final MonitoringEvent event ) { for ( MonitoringEventListener listener : listeners ) { listener.onMonitoringEvent( event ); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy