public abstract class GatewayModule extends Object implements IGatewayModule
GatewayModule class to be extended by the module-creator when creating any modules.| Constructor and Description |
|---|
GatewayModule(long address,
Broker broker,
String configuration)
Constructs a
GatewayModule from the provided address and Broker. |
| Modifier and Type | Method and Description |
|---|---|
void |
create(long moduleAddr,
Broker broker,
String configuration)
The create method is called when the native Gateway creates the Module.
|
abstract void |
destroy()
The destroy method is called on a
GatewayModule before it is about to be "destroyed" and removed from the gateway. |
Broker |
getBroker() |
String |
getConfiguration()
Gets the JSON configuration string for this
GatewayModule |
int |
publish(Message message)
|
void |
receive(byte[] serializedMessage)
The receive method is called on a
GatewayModule whenever it receives a message. |
abstract void |
receive(Message message) |
void |
start()
The start method is called when the native Gateway has created all modules to notify each module that it is safe
to start sending messages.
|
public GatewayModule(long address,
Broker broker,
String configuration)
GatewayModule from the provided address and Broker. A GatewayModule should always call this super
constructor before any module-specific constructor code.
The address parameter must be passed to the super constructor but can be ignored by the module-implementor when writing a module implementation.address - The address of the native module pointer.broker - The Broker to which this module belongsconfiguration - The module-specific configurationpublic abstract void receive(Message message)
public abstract void destroy()
IGatewayModuleGatewayModule before it is about to be "destroyed" and removed from the gateway.
Once a module is removed from the gateway, it may no longer send or receive messages.
The destroy() and receive() methods are guaranteed to not be called simultaneously.destroy in interface IGatewayModulepublic void create(long moduleAddr,
Broker broker,
String configuration)
IGatewayModulecreate in interface IGatewayModulemoduleAddr - The address of the native module pointerbroker - The Broker to which this module belongsconfiguration - The configuration for this module represented as a JSON stringpublic void start()
IGatewayModulestart in interface IGatewayModulepublic void receive(byte[] serializedMessage)
IGatewayModuleGatewayModule whenever it receives a message.
The destroy() and receive() methods are guaranteed to not be called simultaneously.receive in interface IGatewayModuleserializedMessage - The serialized messagepublic int publish(Message message) throws IOException
message - The Message to be publishedIOException - If the Message cannot be serialized.public final Broker getBroker()
public final String getConfiguration()
GatewayModuleGatewayModuleCopyright © 2018. All rights reserved.