001 package com.croftsoft.core.util.state;
002
003 import java.io.Serializable;
004 import java.rmi.*;
005
006 import com.croftsoft.core.lang.ex.*;
007
008 /*********************************************************************
009 *
010 * An ambassador proxy for StateListenerRemote objects.
011 *
012 * @author
013 * <a href="https://www.croftsoft.com/">David Wallace Croft</a>
014 * @version
015 * 1998-12-05
016 *********************************************************************/
017
018 public class StateListenerAmbassador
019 implements StateListener, Serializable
020 //////////////////////////////////////////////////////////////////////
021 //////////////////////////////////////////////////////////////////////
022 {
023
024 private StateListenerRemote stateListenerRemote;
025
026 private transient ExceptionListener exceptionListener;
027
028 //////////////////////////////////////////////////////////////////////
029 //////////////////////////////////////////////////////////////////////
030
031 public StateListenerAmbassador (
032 StateListenerRemote stateListenerRemote,
033 ExceptionListener exceptionListener )
034 //////////////////////////////////////////////////////////////////////
035 {
036 this.stateListenerRemote = stateListenerRemote;
037 this.exceptionListener = exceptionListener;
038 }
039
040 public StateListenerAmbassador (
041 StateListenerRemote stateListenerRemote )
042 //////////////////////////////////////////////////////////////////////
043 {
044 this ( stateListenerRemote, new PrintExceptionListener ( ) );
045 }
046
047 //////////////////////////////////////////////////////////////////////
048 //////////////////////////////////////////////////////////////////////
049
050 public void stateListen ( State state )
051 //////////////////////////////////////////////////////////////////////
052 {
053 try
054 {
055 stateListenerRemote.stateListen ( state );
056 }
057 catch ( Exception ex )
058 {
059 if ( exceptionListener != null )
060 {
061 exceptionListener.threwException ( this, ex );
062 }
063 }
064 }
065
066 //////////////////////////////////////////////////////////////////////
067 //////////////////////////////////////////////////////////////////////
068 }