Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
gemhost_java_example [2020/05/12 18:33] wikiadmin created |
gemhost_java_example [2021/04/14 18:09] (current) wikiadmin |
||
---|---|---|---|
Line 67: | Line 67: | ||
@Override | @Override | ||
public void connectionStatusChanged(int connectionStatus, | public void connectionStatusChanged(int connectionStatus, | ||
- | | + | |
+ | // | ||
} | } | ||
}); | }); | ||
Line 197: | Line 198: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | **Notifications** | ||
+ | |||
+ | The example above demonstrates the most common notification - received events, reports and messages. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | |||
+ | You can publish elements of any type. Here a list is being published. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | To receive notification of the published list, create a method to receive the notification | ||
+ | |||
+ | <code java> | ||
+ | public void ecidListUpdated ( ValueChangedEvent event ) { | ||
+ | System.out.println(" | ||
+ | [...] | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Then create a connector that links from the // | ||
+ | |||
+ | <code java> | ||
+ | Connector connector = DataSourceContainer.getConnectorFor(this, | ||
+ | </ | ||
+ | |||
+ | The ECIDList is part of the ECIDListReply message. First get the ECIDListReply message and then the ECIDList data source and add the connector. | ||
+ | |||
+ | <code java> | ||
+ | ECIDListReply ecidListReply = (ECIDListReply)host.getMessageBean(" | ||
+ | ecidListReply.getDataSource(" | ||
+ | </ | ||
+ | |||
+ | Here's the full code: | ||
+ | |||
+ | <code java> | ||
+ | try { | ||
+ | Connector connector = DataSourceContainer.getConnectorFor(this, | ||
+ | ECIDListReply ecidListReply = (ECIDListReply)host.getMessageBean(" | ||
+ | ecidListReply.getDataSource(" | ||
+ | } catch (Exception e1) { | ||
+ | e1.printStackTrace(); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Every time the ECIDListReply (S2F30) message is received, the ecidListUpdate method will be called. | ||
+ | |||
+ | Normally, the notification would be called only once. However, here, the ECIDList is marked as " | ||
+ | |||
+ | The ECIDList is the last notification in the " | ||
+ | |||
+ | <code java> | ||
+ | public void ecidListUpdated ( ValueChangedEvent event ) { | ||
+ | System.out.println(" | ||
+ | try { | ||
+ | ECIDListReply ecidListReply = (ECIDListReply)host.getMessageBean(" | ||
+ | System.out.println(" | ||
+ | } catch (Exception e) { | ||
+ | e.printStackTrace(); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Be sure to read the section **Advanced Message Matching** in [[Message Matching]] concerning Repeat and Optional before using this approach, but when required it can be a powerful tool. | ||
+ | |||
+ | **Characterization** | ||
+ | |||
+ | An alternative to the above approach to listing ECIDs is to use the characterization capabilities of TransSECS. | ||
+ | |||
+ | Characterization provides a list of all CEIDs, Reports (RPTIDs) and VIDs (SVIDs and ECIDs) available on the tool. Simply call the " | ||
+ | |||
+ | <code java> | ||
+ | Characterize.characterize(host); | ||
+ | </ | ||
+ | |||
+ | This will populate the GEM Host Model maintained by the host. This can be retrieved with the call: | ||
+ | |||
+ | <code java> | ||
+ | host.getGemHostModel(); | ||
+ | </ | ||
+ | |||
+ | |||
+ | Check the GemHostModel JavaDocs for details of the model. | ||