전에 올린 2009/06/02 - [나만의 작업] - JAX-RS @Produces와 @Consumes
에서 많이 본 Java type은 "String"인데, 거기서 본 String은 JAX-RS 구현을 지원하기 위해 필요한 많은 Java type들 중의 하나일뿐이다.
Java type은 byte[], java.io.InputStream, java.io.Reader, java.io.File등이 있다.
게다가 JAXB beans도 지원해준다. 참고로 JAXB의 beans들은 JAXBElement나 @XmlRootElement 나 @XmlType라고 annotation 붙여진 클래스이다.
Example 1.17. Using File with a specific MIME type to produce a response
@GET
@Path("/images/{image}")
@Produces("image/*")
public Response getImage(@PathParam("image") String image) {
File f = new File(image);
if (!f.exists()) {
throw new WebApplicationException(404);
}
String mt = new MimetypesFileTypeMap().getContentType(f);
return Response.ok(f, mt).build();
}
File 타입은 consuming할때 사용되어 진다. 임시파일이 만들어지고 request entity에 저장된다.
'나만의 작업' 카테고리의 다른 글
테스트 코드 작성 관련 링크 (0) | 2010.02.08 |
---|---|
한국 구글 검색 결과 페이지의 'HOT 토픽' (6) | 2009.11.27 |
[Jersey] WebApplicationException and Mapping Exception to Responses (0) | 2009.07.30 |
[Jersey] Building Responses (4) | 2009.07.21 |
[Jersey] Representation and Java Types (0) | 2009.07.16 |
Jersey의 JSON Support (2) | 2009.06.08 |
Jersey의 Exception Handling (0) | 2009.06.05 |
Jersey의 Return Type (0) | 2009.06.04 |
Jersey의 MessageBodyReader/Writer (1) | 2009.06.03 |