Example #1
0
  public static void main(String... args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    ClassroomService classroomService = context.getBean(ClassroomService.class);

    Teacher teacher = new Teacher(1, "Mert");
    Student student1 = new Student(2, "Tugce");

    Person personFetch1 = classroomService.getPerson(teacher);
    System.out.println(personFetch1);

    Person personFetch2 = classroomService.getPerson(student1);
    System.out.println(personFetch2);

    CacheManager cacheManager = context.getBean(CacheManager.class);
    Cache students = cacheManager.getCache("students");
    System.out.println(
        "students cache storage: " + ((ConcurrentHashMap) students.getNativeCache()).values());
    Cache teachers = cacheManager.getCache("teachers");
    System.out.println(
        "teachers cache storage: " + ((ConcurrentHashMap) teachers.getNativeCache()).values());
  }
 @ResponseBody
 @RequestMapping(value = "list", method = RequestMethod.GET)
 public Map<String, Object> listClassroom() {
   Map<String, Object> m = new HashMap<>();
   List<ClassRoom> classrooms;
   try {
     classrooms = classroomDao.listClassroom();
     m.put("item", classrooms);
     return m;
   } catch (Exception ex) {
     m.put("error", ex.getMessage());
     return m;
   }
 }