In the server package, create a new package called provider. Inside, create a new interface called ClassProvider:
Now we need to create the implementation:
We need two private fields. One for the classes we are going to traverse in a moment and one for the classes that contain given annotation. We will use the map in order to make the method faster. The getClassesByAnnotation() method should have the following code:
7.Traversing Classes
Before we continue with our class provider, we need to implement a way to traverse our classes. Implement a new class in the util package called DirectoryViewer. It should contain static method called findControllers():
The implementation of the findControllers() method should be like this:
Now we can go back to the routing.
|