duplicate openmrsclassscanner's in core and rest

Hello all!

found that openmrs-core and the rest module both have an OpenmrsClassScanner

the one in the rest module provides only method

public <T> List<Class<? extends T>> getClasses(Class<? extends T> type, boolean concrete)

and also uses the one from the core.

My questions are:

  • makes sense to add this method to the core?
  • more related to the implementation of both classes

they use the singleton pattern, and static methods getInstance() to return the single instance of the class.

Should they be “Spring-ified” ? With an interface, then (singleton) instance created in applicationContext.xml and dependencies added to classes using it?

Bit nasty to test/mock where these methods are used. Dont want to use powermock.

guess this would break the singleton pattern since springs singleton is only per spring context and the current implementation is (globally) per class loader.

The one in the core platform, searches for classes with a given annotation, while that in the restwebservices module, searches for classes extending or implementing a given type. Though the names are the same, and share a lot in common, they have some differences. I would not be opposed to merging this functionality in core, and deprecate the one in the module with some javadoc telling the consumers that starting with some version of the platform, it is recommended to use the one there. :slight_smile:

ok then, I will create a ticket for it :tools:

created ticket