• 7.Traversing Classes
  • Lab: Web Server Annotation Routing




    Download 1.03 Mb.
    bet3/7
    Sana21.03.2017
    Hajmi1.03 Mb.
    #802
    1   2   3   4   5   6   7

    6.Class Provider


    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.




    Download 1.03 Mb.
    1   2   3   4   5   6   7




    Download 1.03 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Lab: Web Server Annotation Routing

    Download 1.03 Mb.