示例#1
0
  public static void main(String[] args) {

    // 1 - Instanciation du context Spring en faisant référence au fichier des beans 'beans.xml'
    ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");

    // 2- Recuperation d'un bean du conteneur
    IBankonetMetier bankometier1 = (IBankonetMetier) context.getBean("bankonetMetier");

    System.out.println("*****************TEST FONCTIONS DAO*******************");

    // 3-Utilisation du bean
    try {
      bankometier1.ajoutClient(
          new Client(
              "monkey D",
              "luffy",
              "gumgum",
              "bazooka",
              new Adresse(26, "mangrove 41", "CelestIsland")));
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    // bankometier1.effacerClient(1);
    // System.out.println("\nListe des clients de bankometier1"+bankometier1.listerClient());
    // System.out.println(bankometier1.findClients("fajoux"));
    // bankometier1.effacerClient(1551);

  }
 @RequestMapping(value = "/client", method = RequestMethod.PUT)
 @ResponseStatus(HttpStatus.OK)
 @ResponseBody
 public Integer updateClient(@RequestBody Client client) {
   metier.updateClient(client);
   return client.getId();
 }
 @RequestMapping(value = "/client", method = RequestMethod.POST)
 @ResponseStatus(HttpStatus.CREATED)
 @ResponseBody
 public Integer createClient(@RequestBody Client client) {
   metier.addClient(client);
   return client.getId();
 }
 @RequestMapping(value = "/filter/clients/{filter}", method = RequestMethod.GET)
 @ResponseBody
 public List<Client> filterClient(@PathVariable("filter") String filter) {
   return metier.chercherClients(filter);
 }
 @RequestMapping(value = "/client/{id}", method = RequestMethod.DELETE)
 @ResponseStatus(HttpStatus.OK)
 @ResponseBody
 public void deleteClient(@PathVariable("id") Integer id) {
   metier.deleteClient(id);
 }
  @RequestMapping(value = "/client/{id}", method = RequestMethod.GET)
  @ResponseBody
  public Client getClient(@PathVariable("id") Integer id) {

    return metier.editClient(id);
  }
 @RequestMapping(value = "/client", method = RequestMethod.GET)
 @ResponseBody
 public List<Client> getAll() {
   return metier.listClients();
 }