Book Image

Advanced Java EE Development with WildFly

By : Deepak Vohra
Book Image

Advanced Java EE Development with WildFly

By: Deepak Vohra

Overview of this book

<p>This book starts with an introduction to EJB 3 and how to set up the environment, including the configuration of a MySQL database for use with WildFly. We will then develop object-relational mapping with Hibernate 4, build and package the application with Maven, and then deploy it in&nbsp;WildFly 8.1, followed by a demonstration of the use of Facelets in a web application.</p> <p>Moving on from that, we will create an Ajax application in the Eclipse IDE, compile and package it using Maven, and run the web application on WildFly 8.1 with a MySQL database. In the final leg of this book, we will discuss support for generating and parsing JSON with WildFly 8.1.</p>
Table of Contents (18 chapters)
Advanced Java EE Development with WildFly
Credits
About the Author
About the Reviewers
www.PacktPub.com
Disclaimer
Preface
Index

Creating a Java client


In this section, we will use the Jersey client API to create a JAX-RS Web Service client. Create a Java class for a Java client. Select File | New | Other. In New, select Class and click on Next. In the New Java Class wizard, select Source folder as src/main/java, specify Package as org.jboss.jaxrs.rest, and Name as JAXRSClient, which is shown as follows. Then click on Finish.

The org.jboss.jaxrs.rest.JAXRSClient class gets created, as shown here:

Jersey provides a client API to invoke a JAX-RS Web Service. In the Java client, invoke the resource methods using the Jersey client API. Create a resource instance using the com.sun.jersey.api.client.Client class. First, we need to create a ClientConfig object, which represents the client configuration such as property names and features using the no-arguments constructor for DefaultClientConfig. Create a Client object from the ClientConfig object using the static method create(ClientConfig). Create a WebResource object from...