| | JAX-RS, JAXB, and EJB lab
Part 1 - install and start GlassFish
Download and install GlassFish
Follow the instructions in the
installing-GlassFish page (you can skip steps 8 and 9 if you want to, and,
if you prefer some other client, you can install that instead of the RESTful
client)
When you finish this process, the menu
service will be up and running on your PC
Deploy menu-ejb-svc
For information about the menu EJB service, see the
EJB page.
Deploy the menu-ejb-svc.war.
(You may want to use the Web Admin interface at http://localhost:4848 to deploy and be sure that the "Compatibility" box is checked.)
Check that it works. You can use the "menu ejb
svc" drop-down in the RESTful client, or use your favorite client to
interact with http://localhost:8080/menu-ejb-svc/
Part 2 - JAX-RS, JAXB, EJB intro
Open menu-ejb-svc.war with
WinZip and extract the files from the war file and look at
the source files in WEB-INF/classes
In Eclipse (newer versions), you can
- Import > Web > WAR file
- import from menu-ejb-svc.war
- you can hit Finish in the WAR Import dialog. If
you continue into the WAR Import: Web libraries dialog, make sure the
Jersey jar files are UN-selected.
- Delete index.jsp and WebContent/WEB-INF/sun-web.xml
(if it's there)
- If Eclipse on your lab PC won't do this, you'll
have to do more manual work:
- create a dynamic web project
- import the menu package from menu-ejb-svc.war
- import the web.xml from menu-ejb-svc.war
- import the jar files from menu-ejb-svc.war to
WebContent/WEB-INF/lib
- Import > EJB > EJB JAR file
- import from menu-ejb.jar
- add menu-ejb-client.jar to the project's build
path
Your instructor will give a short introduction to JAX-RS,
(a small piece of) JAXB, and EJB using the menu EJB service source as an example.
- JAX-RS
- @Path
- @GET, @POST, @PUT, @DELETE
- @PathParam
- Request content
- @Produces, @Consumes
- Response class
- @Provider
- JAXB
- @XmlRootElement
- @XmlElement
- @XmlAttribute
- @XmlType
- EJB
Part 3 - Build a directory service front-end
- Deploy directory
service reference implmenetation
- Create and annotate DirectoryEntry class
- Create and annotate DirectoryResource class
- add the directory client jar to your classpath
- getEntry method
- lookup directory service
- web.xml
- deploy
- test with RESTful client
- createEntry method
- re-deploy
- test with RESTful client
- compare with directory
service front-end demo
|