WebLogic ServerでJAX-RS

  • View
    1.451

  • Download
    2

Embed Size (px)

DESCRIPTION

JAX-RSRESTful WebAPIJAX-RSJava EE 6 WebLogic Server 11g RESTful Web JAX-RSWebLogic Server GlassFish

Transcript

  • 1. JAX-RS on WebLogicMarch 21, 2013HASUNUMA Kenji Vice president, GlassFish Users Group Japank.hasunuma@coppermine.jp Twitter: @btnrouge (#wlstudy)

2. Jersey JAX-RS Since 2008 3. Introduction 4. HTTP (GET) World Wide WebHTML 5. HTTP (POST) HTML = Web 6. HTTP (REST)Web REST (Representational State Transfer) 7. HTTP Status / 31xx 2xx 3xx ()4xx ()5xx () 8. Whats REST? 9. RESTful Web?REST3 () URIStatelessWeb 10. REST3 - URI : : HTML : Web 11. REST3 - GET POST PUT DELETE HEAD OPTIONS 12. REST3 - URI (Unied Resource Identier) Unix = URL 13. Core Features 14. JAX-RS1 15. REST3JAX-RS (POJO) + @GET, @POST, @PUT, @DELETE URI () @Path 16. POJO @Path EJB(Stateless or Singleton)EJBCDI 17. @Path(/hello)public class HelloResource {@GET@Consumes(application/x-www-urlencoded)@Produces(text/plain)public String sayHello(@QueryParam(q) String name) {return Hello, + name;}} 18. GET /hello?q=everybody@Path(/hello)public class HelloResource {@GET@Consumes(application/x-www-urlencoded)@Produces(text/plain) ResponseRequestpublic String sayHello(@QueryParam(q) String name) {return Hello, + name;}} 19. @QueryParam @FormParam@PathParamURI@MatrixParam Matrix URI@HeaderParam @CookieParam () 20. GET /hello/everybody : @PathParam@Path(/hello/{q})public class HelloResource {@GET@Consumes(application/x-www-urlencoded)@Produces(text/plain) ResponseRequestpublic String sayHello(@PathParam(q) String name) {return Hello, + name;}} 21. : @MatrixParamGET /position;latitude=35.75;longitude=139.72@Path("/position")public class PositionResource {@GETpublic String getPosition( @MatrixParam("latitude") double latitude, @MatrixParam("longitude") double longitude) { return String.format("%3.2f%s %3.2f%s", Math.abs(latitude), latitude == 0.0 ? "" : (latitude > 0.0 ? "N" : "S"), Math.abs(longitude), longitude == 0.0 ? "" : (longitude > 0.0 ? "E" : "W")); }} 22. JavaMIME JavaMIMEbyte[ ]StringMIME InputStream (*/*)Reader text/xmlJavaBean application/xml (JAXB)application/jsonMultivaluedMap application/x-www-urlencoded Booleantext/plainCharacter auto-boxing Number 23. MIME : MessageBodyReader MessageBodyWriter JAXBJAXB byte[ ]InputStream () 24. JAX-RSHTTP 200 (OK) 500 (Internal Server Error) 25. JAX-RSHTTP500(: 400) WebApplicationException 26. JAX-RSHTTP JAX-RSRESTful /HTTP HTTP HTTP 27. How to deploy 28. JAX-RS Web :1. Application (web.xmlWLS 12c)2. (web.xmlWLS 11g (10.3.4-)) 29. Application// WebLogic 12c@ApplicationPath(/app)public MyApplication extends Application {// }URL:http://hostname/context-root/app/hello 30. Jerseycom.sun.jersey.spi.container.servlet.ServletContainerJersey/app/* 31. OEPE Web (Servlet/JSP) WebLogic () weblogic.xml 32. (JAX-RS) jsr311-api JAX-RS API & jersey-bundle jackson-core-asljackson-mapper-aslJAXBjackson-jaxrs(JSON)() jettisonrome Atom 33. (JAX-RS) 34. Demonstrations 35. Programming JAX-RS 36. (JAX-RS) PC Web : WebLogicJAX-RS 37. 1. ? ?2.URI 3. 38. (Web)JAX-RS http://jsr311.java.net (JSR 311) http://jersey.java.net (Jersey) () http://www.coppermine.jp/docs/programming/ 39. () RESTful WebLeonard Richardson, Sam Ruby ISBN978-4873113531 JavaRESTfulBill Burke ISBN978-4873114675 Beginning Java EE 6Antonio Goncalves ISBN978-4798124605 40. JAX-RS on WebLogicMarch 21, 2013 HASUNUMA Kenji k.hasunuma@coppermine.jp