Package org.djutils.rmi
Class RMITest.Producer
java.lang.Object
java.rmi.server.RemoteObject
java.rmi.server.RemoteServer
java.rmi.server.UnicastRemoteObject
org.djutils.rmi.RMIObject
org.djutils.rmi.RMITest.Producer
- All Implemented Interfaces:
Serializable
,Remote
,RMITest.ProducerInterface
- Enclosing class:
- RMITest
public class RMITest.Producer extends org.djutils.rmi.RMIObject implements RMITest.ProducerInterface
Producer object.
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Producer()
Register the producer on the localhost RMI registry at the default port.Producer(String host, int port, String bindingKey)
Register this object in the RMI registry.Producer(URL registryURL, String bindingKey)
Register this object in the RMI registry. -
Method Summary
Modifier and Type Method Description void
addListener(RMITest.ListenerInterface listener)
Add a listener to the producer.protected void
fire(String payload)
Fire a message.Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, exportObject, exportObject, unexportObject
-
Constructor Details
-
Producer
Register the producer on the localhost RMI registry at the default port.- Throws:
RemoteException
- on network errorAlreadyBoundException
- on error
-
Producer
public Producer(String host, int port, String bindingKey) throws RemoteException, AlreadyBoundExceptionRegister this object in the RMI registry.- Parameters:
host
- String; the host where the RMI registry resides or will be created.port
- int; the port where the RMI registry can be found or will be createdbindingKey
- the key under which this object will be bound in the RMI registry- Throws:
RemoteException
- when there is a problem with the RMI registryAlreadyBoundException
- when there is already another object bound to the bindingKeyNullPointerException
- when host, path, or bindingKey is nullIllegalArgumentException
- when port < 0 or port > 65535AccessException
- when there is an attempt to create a registry on a remote host
-
Producer
Register this object in the RMI registry.- Parameters:
registryURL
- URL; the URL of the registry, e.g., "http://localhost:1099"bindingKey
- String; the key under which this object will be bound in the RMI registry- Throws:
RemoteException
- when there is a problem with the RMI registryAlreadyBoundException
- when there is already another object bound to the bindingKeyNullPointerException
- when registryURL or bindingKey is nullAccessException
- when there is an attempt to create a registry on a remote host
-
-
Method Details
-
addListener
Add a listener to the producer.- Specified by:
addListener
in interfaceRMITest.ProducerInterface
- Parameters:
listener
- the listener to add- Throws:
RemoteException
- on network error
-
fire
Fire a message.- Parameters:
payload
- String the payload to send to the listener- Throws:
RemoteException
- on network error
-