Package sample.hello.bean

Examples of sample.hello.bean.Contact


  private static void initOneContact() {
    Address[] addrs = {
      new Address("Shanghai", "Long Hua Street"),
      new Address("Shanghai", "Dong Quan Street")
    };
    Contact cHuang = new Contact("huangyim", "Huang Yi Ming", Arrays.asList(addrs));
    store.put(cHuang.getId(), cHuang);
  }
View Full Code Here


    postForm(r, "foo", "bar");
   
    Address[] addrs = {
      new Address("Shanghai", "Ke Yuan Street")
    };
    Contact cnt = new Contact("guoqing", "Guo Qing", Arrays.asList(addrs));
   
    System.out.println("===== Create guoqing =====");
    putOneContact(r, cnt);
   
    System.out.println("===== All Contacts =====");
View Full Code Here

   
    // 3, get JAXB response
    GenericType<List<Contact>> genericType = new GenericType<List<Contact>>() {};
    List<Contact> contacts = r.accept(MediaType.APPLICATION_XML).get(genericType);
    System.out.println("No. of Contacts: " + contacts.size());
    Contact contact = contacts.get(0);
    System.out.println(contact.getId() + ": " + contact.getName());
  }
View Full Code Here

  }
 
  public static void getOneContact(WebResource r, String id) {
    GenericType<JAXBElement<Contact>> generic = new GenericType<JAXBElement<Contact>>() {};
    JAXBElement<Contact> jaxbContact = r.path(id).accept(MediaType.APPLICATION_XML).get(generic);
    Contact contact = jaxbContact.getValue();
    System.out.println(contact.getId() + ": " + contact.getName());
  }
View Full Code Here

  public void newContact(
      @FormParam("id") String id,
      @FormParam("name") String name,
      @Context HttpServletResponse servletResponse
  ) throws IOException {
    Contact c = new Contact(id,name,new ArrayList<Address>());
    ContactStore.getStore().put(id, c);
   
    URI uri = uriInfo.getAbsolutePathBuilder().path(id).build();
    Response.created(uri).build();
   
View Full Code Here

  }
 
  @GET
  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  public Contact getContact() {
    Contact cont = ContactStore.getStore().get(contact);
    if(cont==null)
      throw new NotFoundException("No such Contact.");
    return cont;
  }
View Full Code Here

  }
 
  @PUT
  @Consumes(MediaType.APPLICATION_XML)
  public Response putContact(JAXBElement<Contact> jaxbContact) {
    Contact c = jaxbContact.getValue();
    return putAndGetResponse(c);
  }
View Full Code Here

  }
 
  @PUT
  public Response putContact(@Context HttpHeaders herders, byte[] in) {
    Map<String,String> params = ParamUtil.parse(new String(in));
    Contact c = new Contact(params.get("id"), params.get("name"),
        new ArrayList<Address>());
    return putAndGetResponse(c);
  }
View Full Code Here

    return res;
  }
 
  @DELETE
  public void deleteContact() {
    Contact c = ContactStore.getStore().remove(contact);
    if(c==null)
      throw new NotFoundException("No such Contact.");
  }
View Full Code Here

TOP

Related Classes of sample.hello.bean.Contact

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.