Module Activator

Hello, I have got a question about the activator class in my new module. Is the activator class with the code, provided in openmrs-module-basicmodule/BasicModuleActivator.java at eec759d55dfed263eadf51ac487f12e535be2787 · openmrs/openmrs-module-basicmodule · GitHub enough or is there something to add?

It seems like that the activator class is never starting. Any thoughts about that? Is this due to a version problem?

My activator class looks like in the link given below.

And therefore, what is the difference between writing the following:

public class ABC extends BaseModuleActivator implements ModuleActivator

public class BasicModuleActivator implements Activator

Is this due to different versions? And how to write it in the platform-module? I red that the activator class was updated in the reference-application-module but what about the platform-module?

hello @armin

Every module in openmrs must implement the interface 'org.openmrs.module.ModuleActivator' to execute some needed logic upon each module start-up.

Also the activator interface was deprecated .

You can read about it here

Which activator interface is deprecated?

This one: Module Activator - Documentation - OpenMRS Wiki

So you mean that in my activator class I have to write org.openmrs.module.ModuleActivator instead of import org.openmrs.module.BaseModuleActivator;

Is the BaseModuleActivator outdated or do I need both of them?

org.openmrs.module.Activator

Alright. Thanks. And what is the difference to import org.openmrs.module.BaseModuleActivator; ?

Is the BaseModuleActivator also outdated?

you should extend BaseModuleActivator instead of directly implementing this interface for forward compatibility of subclasses.

Yes, so now my class looks like:

public class DeviceconnectorActivator extends BaseModuleActivator

Do I have to implement org.openmrs.module.ModuleActivator in addition to that that it looks like following?

public class DeviceconnectorActivator extends BaseModuleActivator implements ModuleActivator

not really,

the BaseModuleActivator is an abstract class that implements the ModuleActivator interface and must be extended by modules and referenced by the Module-Activator property in the module manifest

just simply extend the base module activator

public class DeviceconnectorActivator extends BaseModuleActivator

@gcliff I understand. One more question. What do you mean by the “ModuleActivator` interface and must be extended by modules and referenced by the Module-Activator property in the module manifest”

In which file do I have to add something?

@gcliff Does my class public class DeviceconnectorController has to extend the ModuleActivator too that it can be recognized?

i do this in your module activator class

u can have a sample look at this in the fhir module

But here is also just the public class FhirActivator extends BaseModuleActivator class an no public interface ModuleActivator right?

yes base module activator already implements the ModuleActivator interface in the background

Alright, got it! Thank you!

1 Like

@gcliff I am not sure if you would have time for that. But my own created module is still not working. So the module can not be find. There is always a http 404 error code, so the module cannot be shown and I do not know what is missing.

Maybe you could take a short look into my module?

I described the problem already here: Problem with Request Mapping and Controller in new created module

But no one could give me any advice.

Thanks in advance!

I have commented on the other thread.