Package org.djutils.demo.rmi
Class Producer
- java.lang.Object
-
- java.rmi.server.RemoteObject
-
- java.rmi.server.RemoteServer
-
- java.rmi.server.UnicastRemoteObject
-
- org.djutils.rmi.RMIObject
-
- org.djutils.demo.rmi.Producer
-
- All Implemented Interfaces:
Serializable,Remote,ProducerInterface
public class Producer extends RMIObject implements ProducerInterface
Producer.java.Copyright (c) 2019-2021 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUTILS License.- Author:
- Alexander Verbraeck
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.rmi.server.RemoteObject
ref
-
-
Constructor Summary
Constructors Constructor Description Producer()Register the producer on the localhost RMI registry at the default port.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(ListenerInterface listener)Add a listener to the producer.protected voidcommands()create a small interactive application.protected voidfire(String payload)Fire a message.static voidmain(String[] args)System.exit(...) calls help to shut down RMI / socket thread that might wait for a timeout.-
Methods inherited from class org.djutils.rmi.RMIObject
getRegistry, register
-
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, exportObject, exportObject, unexportObject
-
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
-
-
-
-
Constructor Detail
-
Producer
public Producer() throws RemoteException, AlreadyBoundExceptionRegister the producer on the localhost RMI registry at the default port.- Throws:
RemoteException- on network errorAlreadyBoundException- on error
-
-
Method Detail
-
addListener
public void addListener(ListenerInterface listener) throws RemoteException
Add a listener to the producer.- Specified by:
addListenerin interfaceProducerInterface- Parameters:
listener- the listener to add- Throws:
RemoteException- on network error
-
fire
protected void fire(String payload) throws RemoteException
Fire a message.- Parameters:
payload- String the payload to send to the listener- Throws:
RemoteException- on network error
-
commands
protected void commands()
create a small interactive application.
-
main
public static void main(String[] args)
System.exit(...) calls help to shut down RMI / socket thread that might wait for a timeout.- Parameters:
args- nothing needed
-
-