001 package com.croftsoft.core.util.state; 002 003 import java.rmi.*; 004 import java.rmi.server.UnicastRemoteObject; 005 006 /********************************************************************* 007 * 008 * An adapter for StateMulticasters of remote States. 009 * 010 * @author 011 * <a href="https://www.croftsoft.com/">David Wallace Croft</a> 012 * @version 013 * 1998-12-05 014 *********************************************************************/ 015 016 public class StateMulticasterProxy 017 extends UnicastRemoteObject implements StateMulticasterRemote 018 ////////////////////////////////////////////////////////////////////// 019 ////////////////////////////////////////////////////////////////////// 020 { 021 022 private StateMulticaster stateMulticaster; 023 024 ////////////////////////////////////////////////////////////////////// 025 ////////////////////////////////////////////////////////////////////// 026 027 public static void main ( String [ ] args ) 028 ////////////////////////////////////////////////////////////////////// 029 { 030 String name = "StateMulticasterProxy"; 031 032 if ( args.length > 0 ) name = args [ 0 ]; 033 034 try 035 { 036 Naming.rebind ( name, new StateMulticasterProxy ( 037 new QueuedStateMulticaster ( ) ) ); 038 } 039 catch ( Exception ex ) 040 { 041 ex.printStackTrace ( ); 042 } 043 } 044 045 ////////////////////////////////////////////////////////////////////// 046 ////////////////////////////////////////////////////////////////////// 047 048 public StateMulticasterProxy ( StateMulticaster stateMulticaster ) 049 throws RemoteException 050 ////////////////////////////////////////////////////////////////////// 051 { 052 this.stateMulticaster = stateMulticaster; 053 } 054 055 ////////////////////////////////////////////////////////////////////// 056 ////////////////////////////////////////////////////////////////////// 057 058 public void update ( State state ) 059 throws RemoteException 060 ////////////////////////////////////////////////////////////////////// 061 { 062 stateMulticaster.update ( state ); 063 } 064 065 public boolean addStateListener ( StateListener stateListener ) 066 throws RemoteException 067 ////////////////////////////////////////////////////////////////////// 068 { 069 return stateMulticaster.addStateListener ( stateListener ); 070 } 071 072 public boolean removeStateListener ( StateListener stateListener ) 073 throws RemoteException 074 ////////////////////////////////////////////////////////////////////// 075 { 076 return stateMulticaster.removeStateListener ( stateListener ); 077 } 078 079 080 ////////////////////////////////////////////////////////////////////// 081 ////////////////////////////////////////////////////////////////////// 082 }