void writeTo ( Object o , Class type ,
Type genericType , Annotation  annotations ,
MediaType mediaType ,
MultivaluedMap httpHeaders , OutputStream os )
throws IOException , WebApplicationException
ObjectOutputStream oos = new
new ObjectOutputStream ( os );
oos . writeObject ( o );
Like the readFrom() method, basic Java serialization is used to marshal our Java object into
the HTTP response body.
The Resource Class
The CustomerResource class doesn't change much from ex06_2 :
@Path ( "/customers" )
@Consumes ( " application / example - java ")
public Response createCustomer(Customer customer)
System.out.println(" Created customer " + customer.getId());
return Response.created(URI.create(" / customers / "
+ customer . getId ())). build ();
The code is actually exactly the same as that used in ex06_1 , except that the @Produces and
@Consumes annotations use the application/example-java media type.
The Application Class
The ShoppingApplication class needs to change a tiny bit from the previous examples: