001    /*
002     * Copyright 2005-2006 Stephen J. McConnell.
003     *
004     * Licensed  under the  Apache License,  Version 2.0  (the "License");
005     * you may not use  this file  except in  compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *   http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed  under the  License is distributed on an "AS IS" BASIS,
012     * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
013     * implied.
014     *
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    
019    package net.dpml.metro.runtime;
020    
021    import java.rmi.RemoteException;
022    
023    import net.dpml.component.Disposable;
024    
025    import net.dpml.util.EventQueue;
026    import net.dpml.util.Logger;
027    
028    /**
029     * A abstract base class that established an event queue and handles event dispatch 
030     * operations for listeners declared in a class extending this base class.
031     *
032     * @author <a href="http://www.dpml.net">Digital Product Meta Library</a>
033     * @version 1.2.0
034     */
035    public abstract class UnicastEventSource extends net.dpml.util.UnicastEventSource implements Disposable
036    {
037        private boolean m_disposed = false;
038    
039       /**
040        * Creation of a new <tt>UnicastEventSource</tt>.
041        * @param queue the system event queue
042        * @param logger the assigned logging channel
043        * @exception RemoteException if a remote I/O exception occurs
044        */
045        protected UnicastEventSource( EventQueue queue, Logger logger ) throws RemoteException
046        {
047            super( queue, logger );
048        }
049        
050        //--------------------------------------------------------------------------
051        // Disposable
052        //--------------------------------------------------------------------------
053        
054       /**
055        * Retun the disposed state of this event source.
056        * @return true if disposed
057        */
058        protected boolean isDisposed()
059        {
060            return m_disposed;
061        }
062       
063       /**
064        * Handle instance disposal.
065        */
066        public void dispose()
067        {
068            if( !m_disposed )
069            {
070                super.terminate();
071                m_disposed = true;
072            }
073        }
074        
075        //--------------------------------------------------------------------------
076        // internal
077        //--------------------------------------------------------------------------
078        
079       /**
080        * Return the logging channel assigned to the event source.
081        * @return the logging channel
082        */
083        Logger getLogger()
084        {
085            return super.getLocalLogger();
086        }
087    }