Should we make Module.setExtension private or remove it?

Hi there,

while testing and later refactoring (issue) Module.getExtensions() I found that we provide the setter Module.setExtensions() which is never used in openmrs-core and actually overwrites the logic in Module.getExtensions() which creates the Extension classes based on the modules config.xml extension entries like for example in the reporting module

<extension>
	<point>org.openmrs.admin.list</point>
	<class>org.openmrs.module.web.extension.ManageAdminListExt</class>
</extension>

I feel like this might have been an oversight, or an auto-generated setter. When a module is loaded the ModuleFileParser.parse() creates a Module instance and sets the extensionNames which is a simple map representing the above xml extension elements. When one calls module.getExtensions() actual instances of the extension classes defined in the config.xml are created and stored.

However, it is possible to override this logic afterwards with module.setExtensions(). I wonder if this is intentional.

What do you think?

How about modifying Module.setExtensions() to do the logic that is currently in Module.getExtensions() such that Module.getExtensions() turns into a mere getter with no extra processing logic?

We dont use Module.setExtensions() at all. The ModuleFileParser which constructs a Module from a config.xml uses Module.setExtensionNames to store point, classnames in a map. At this point we do not create instances of Extension defined in config.xml. I am not sure if this separation of reading config.xml, creating a Module and then creation of Extension was done on purpose.

Then in that case i would vote for deprecating Module.setExtensions() for eventual removal.