@@ -11,7 +11,7 @@ JVM will interact with the native gateway core.
11
11
Design
12
12
------
13
13
14
- ![ ] ( Design .png)
14
+ ![ ] ( HLD1 .png)
15
15
16
16
Java Module Host
17
17
----------------
@@ -21,7 +21,8 @@ The **Java Module Host** is a C module that
21
21
1 . Creates the JVM (Java Virtual Machine) the first time a Java module is
22
22
attempting to connect to the gateway.
23
23
24
- 2 . Brokers calls ** to** the Java module (create, destroy, receive).
24
+ 2 . Brokers calls ** to** the Java module (create, destroy, receive) and
25
+ facilitates publishing ** from** the Java module to the native Message Bus.
25
26
26
27
Because [ JNI] ( http://docs.oracle.com/javase/8/docs/technotes/guides/jni/ ) (Java
27
28
Native Interface) only allows one JVM instance per process, the ** Java Module
@@ -30,14 +31,15 @@ Subsequent attempts to load additional Java modules will load and run those
30
31
modules in the same JVM that was originally created. The JSON configuration for
31
32
this module will be similar to the configuration for the Node Module Host:
32
33
33
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ json
34
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ json
34
35
{
35
36
"modules" : [
36
37
{
37
38
"module name" : " java_poller" ,
38
- "module path" : " /path/to/java_module_host .so|.dll" ,
39
+ "module path" : " /path/to/java_module_host_hl .so|.dll" ,
39
40
"args" : {
40
41
"class_path" : " /path/to/relevant/class/files" ,
42
+ "library_path" : " /path/to/dir/with/java_module_host_hl.so|.dll"
41
43
"class_name" : " Poller" ,
42
44
"args" : {
43
45
"frequency" : 30
@@ -57,35 +59,6 @@ this module will be similar to the configuration for the Node Module Host:
57
59
}
58
60
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59
61
60
- or:
61
-
62
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ json
63
- {
64
- "modules" : [
65
- {
66
- "module name" : " java_poller" ,
67
- "module path" : " /path/to/java_module_host.so|.dll" ,
68
- "tags" : [" java" ],
69
- "args" : {
70
- "class_path" : " /path/to/relevant/class/files" ,
71
- "class_name" : " Poller" ,
72
- "args" : {
73
- "frequency" : 30
74
- }
75
- }
76
- }
77
- ]
78
- }
79
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80
-
81
- * You might have noticed a tags section. When processing the input JSON
82
- configuration file, the Gateway SDK will insert everything within the JSON
83
- object for the specified tag within the tags array into the args section for the
84
- corresponding module (please see \_\_\_\_ for more detailed guidance on
85
- constructing a JSON configuration).*
86
-
87
-
88
-
89
62
As usual, the `module path` specifies the path to the DLL/SO that implements the
90
63
**Java Module Host**. The `args.class_path` specifies the path to the directory
91
64
where all necessary Java class files are located, `args.class_name` is the name
@@ -101,20 +74,19 @@ The **Java Module Host** will handle calling into the gateway module written in
101
74
Java when necessary, therefore each module written in Java must implement the
102
75
same `IGatewayModule` interface shown below:
103
76
104
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ java
77
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ java
105
78
public interface IGatewayModule {
106
79
107
80
/**
108
81
* The create method is called by the subclass constructor when the native
109
82
* Gateway creates the Module. The constructor
110
83
* should save both the {@code moduleAddr} and {@code bus} parameters.
111
84
*
112
- * @param moduleAddr The address of the native module pointer
113
85
* @param bus The {@link MessageBus} to which this Module belongs
114
86
* @param configuration The configuration for this module represented as a JSON
115
87
* string
116
88
*/
117
- void create (long moduleAddr , MessageBus bus , String configuration );
89
+ void create(MessageBus bus, String configuration);
118
90
119
91
/**
120
92
* The destroy method is called on a {@link GatewayModule} before it is about
@@ -134,9 +106,9 @@ public interface IGatewayModule {
134
106
* The destroy() and receive() methods are guaranteed to not be called
135
107
* simultaneously.
136
108
*
137
- * @param buffer The message content
109
+ * @param source The message content
138
110
*/
139
- void receive (byte [] buffer );
111
+ void receive(byte[] source );
140
112
}
141
113
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
142
114
@@ -163,20 +135,19 @@ gateway, it:
163
135
- Constructs a `MessageBus` Java object using the `MESSAGE_BUS_HANDLE`.
164
136
165
137
- Finds the module’s class with the name specified by the `args.class_name`,
166
- invokes the constructor passing in the ` MODULE_HANDLE ` , ` MessageBus ` object,
167
- the JSON args string for that module, and creates the Java module.
138
+ invokes the constructor passing in the `MessageBus` object and the JSON args
139
+ string for that module, and creates the Java module.
168
140
169
- - Gets a global reference to the newly created ` GatewayModule ` object to be saved by
170
- the ` JAVA_MODULE_HOST_HANDLE ` .
141
+ - Gets a global reference to the newly created `GatewayModule` object to be
142
+ saved by the `JAVA_MODULE_HOST_HANDLE`.
171
143
172
144
### Module\_Receive
173
145
174
146
When the **Java Module Host**’s `Module_Receive` function is invoked by the
175
147
gateway, it:
176
148
177
149
- Serializes the `MESSAGE_HANDLE` content and properties and invokes the
178
- ` receive ` method implemented by the Java module with the ` MODULE_HANDLE ` and
179
- the serialized message.
150
+ `receive` method implemented by the Java module with the serialized message.
180
151
181
152
### Module\_Destroy
182
153
@@ -194,12 +165,10 @@ gateway, it:
194
165
Communication **FROM** the Java module
195
166
--------------------------------------
196
167
197
- As previously mentioned, the ** Java Module Host** will only handle communication
198
- from the native gateway process ** to** the Java module. In order to communicate
199
- ** from** the Java module to the native gateway process, the ` MessageBus ` class
200
- must be used. The ` MessageBus ` class provides a method to publish messages onto
201
- the native Message Bus and loads a dynamic library that implements expected
202
- functions for publishing onto the native Message Bus. So, the above diagram
203
- should look a bit more like this:
168
+ In order to communicate **from** the Java module to the native gateway process,
169
+ the `MessageBus` class must be used. The `MessageBus` class provides a method to
170
+ publish messages onto the native Message Bus and loads a dynamic library that
171
+ implements expected functions for publishing onto the native Message Bus. So,
172
+ the above diagram should look a bit more like this:
204
173
205
- ![ ] ( Design2 .png)
174
+ 
0 commit comments