Skip to content

KrishnanandSingh/JAWF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EmployeeWebApp

Built up as an implementation of yet another web framework based on front controller pattern and reflection.


Working

com.kn.processor is the package where most of the magic happens. It defines two annotations @RequestHandler and @URLMapping.

// a class should be annotated with this to declare that it wants to process web requests.
@RequestHandler

// methods annotated with this are forwarded the web requests defined by the urlPattern
@URLMapping(urlPattern="/getAllEmployees.do")

FrontController serves as the entry point of the app. On its initialisation, it tells the annotation processor where web controllers are defined.

String[] packages = new String[] { "com.kn.controller" };
HandlerFactory.initializeHandlers(getClass().getClassLoader(), packages);

HandlerFactory asks AnnotationProcessor to look for the classes annotated with @RequestHandler and gets the methods annotated with @URLMapping. With the relevant method a Handler object is created with the object and the method reference. This Handler object is stored in a map with the urlParameter value as key. When FrontController recieves a request it looks into this map for a handler to be present and passes the control.

Rest everything is related to the crud operations on an employee. The frontend is built using AngularJS v1.5.


To run

  • create database employee_sdet;
  • mysql -uroot -pyourpassword employee_sdet < employee_sdet.sql;
  • edit src/main/java/config.properties to change db password