...
Require Module – The following code should be placed in yours config.xml file to insure that RDT is always loaded before your module can be installed in the OpenMRS system. This will insure that you are always able to register listeners with the module when the system is started (see below for registering listeners).<require_modules>
<require_module>org.openmrs.module.remotedatatransfer</require_module>
</require_modules>
Implement RemoteDataTransferListener – To be informed of when new data arrives for your module it is necessary to implement a listener. This is a class that inplements the RemoteDataTransferListener interface. An example of what this class might look like is below. The main function of this class is to allow code from within your module to be executed when data arrives that has been tagged with the tags that your module is setup to listen for. These tags are also specified in your implementation of this interface:
Code Block |
---|
public class TestModule Listener implements RemoteDataTransferListener { protected final Log log = LogFactory.getLog(getClass()); @Override public void dataReceived(RemoteDataTransferReceivedItem receivedItem) { //PERFORM ACTIONS HERE } @Override public List<String> getSupportedTags() { String\[\] list = {"kdmtestmodule1","kdmtestmodule2"}; return Arrays.asList(list); } } |
...
Register Listener – In order for the listener that has been implemented to be registered with RDT the following code must be added in yours module's moduleApplicationContext.xml.
Code Block |
---|
<bean class="org.openmrs.module.remotedatatransfer.impl.RemoteDataTransferServiceImpl">
<property name="listener">
<bean id="moduleListener" class=" (MODULE_PACKAGE).ModuleListener"/>
</property>
</bean>
|
note
...
-
...
ModuleListener
...
should
...
be
...
replaced
...
by
...
the
...
name
...
of
...
your
...
implemented
...
module
...
listener
...
class.
...
[edit]
Service/API Methods
After setting up the module API functions are made available by starting the RDT service. This is done as follows:
Code Block |
---|
RemoteDataTransferService service = Context.getService(RemoteDataTransferService.class); |
Now service methods can be called using the newly created service object. For example to send data:
Code Block |
---|
service.sendData("DATA0101", service.getServer("SERVER001"),"TAG1"); \\ |
[edit]
Known Issues
Out of memory error
...