Book Image

JBoss AS 7 Development - Second Edition

By : Francesco Marchioni
Book Image

JBoss AS 7 Development - Second Edition

By: Francesco Marchioni

Overview of this book

JBoss Application Server meets high standards of reliability, efficiency, and robustness, and is used to build powerful and secure Java EE applications. It supports the most important areas of Java Enterprise programming including EJB 3.1, Contexts and Dependency Injection, JAX-WS and JAX-RS web services, the security framework, and more. Getting started with JBoss application server development can be challenging; however, with the right approach and guidance, you can easily master it and this book promises that.Written in an easy-to-read style, this book will take you from the basics of JBoss AS—such as installing core components and plugins—to the skills that will make you a JBoss developer to be reckoned with, covering advanced topics such as developing applications with the JBoss messaging service, JBoss web services, clustered applications, and more.You will learn the necessary steps to install a suitable environment for developing enterprise applications on JBoss AS. You will also learn how to design Enterprise applications using Eclipse, JBoss plugins, and Maven to build and deploy your applications. Readers will learn how to enable distributed communication using JMS. Storing and retrieving objects will be made easier using the Java Persistence API. The core section of the book will take you into the programming arena with tested, real-world examples. The example programs have been carefully crafted to be easy to understand and useful as starting points for your applications. This practical guide will show you how to gain hands-on experience rapidly on Java EE development using JBoss AS with easy-to-understand and practical programming examples.
Table of Contents (19 chapters)
JBoss AS 7 Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

The JBoss Application Server is a certified platform for Java EE for developing and deploying Java Enterprise applications. The JBoss Application Server provides the full range of Java EE 1.6 features as well as extended Enterprise services, including clustering, caching, and persistence. This book will show Java EE developers how to develop their applications using the JBoss Application Server and the widely used Eclipse environment combined with the Maven framework, which will greatly increase your productivity. The whole learning process is arranged through a common theme application, the Ticket Booking application, that progressively increases in complexity as new topics are introduced.

What this book covers

Chapter 1, Getting Started with JBoss AS 7, discusses installing the core application server distribution and all the required tools for running it and for developing Java EE applications (JVM, Eclipse, and Maven).

Chapter 2, What's New in JBoss AS 7, provides a crash course on JBoss AS 7. It introduces the new filesystem structure, the application's configuration, and the dichotomy between standalone servers and domain servers.

Chapter 3, Beginning Java EE 6 – EJBs, discusses the new features introduced by EJB 3.1, including Singleton EJB, Asynchronous EJB, and EJB Timer Service. We will develop our Ticket Booking application, which will be the main theme of the book.

Chapter 4, Learning Context Dependency Injection, introduces Context Dependency Injection, comparing its features with the older EJB and JSF programming models. We will show how to enhance out ticket system using CDI annotations.

Chapter 5, Combining Persistence with CDI, discusses the Java Persistence API, showing how we can persist data on a relational database. We will then combine the JPA API with the example developed in the earlier chapters.

Chapter 6, Testing Your Applications, introduces Arquillian, showing how to use it for testing your application using a running application server instance or by managing its own server instance.

Chapter 7, Developing Applications with JBoss JMS Provider, discusses the Java Message Service, showing how you can configure some core JMS elements (such as factories and destinations) on your server. Next, we will enhance our Ticket example by adding a JMS producer and consumer. The last part of this chapter deals with advanced concepts, such as consuming messages from an external JMS provider.

Chapter 8, Adding Web Services to Your Applications, talks about the two core web services stacks: SOAP-based web services and RESTful web services; it provides concrete examples and highlights the differences between the two approaches.

Chapter 9, Managing the Application Server, talks about the core concepts of the Command Line Interface and how it can improve your productivity. The next part of this chapter dives deep into writing CLI scripts using other languages such as Jython.

Chapter 10, Clustering JBoss AS 7 Applications, is all about the world of clustered applications. We will learn how to use the robust clustering features of JBoss AS applied to some of the examples discussed in this book.

Chapter 11, Securing JBoss AS 7 Applications, will show how to use security domains to perform required authorization and authentication checks. The next part of this chapter discusses securing the data that is transmitted from the client to the server and vice versa.

Appendix, Rapid Development Using JBoss Forge, is the last section of this book; it is about the JBoss Forge framework. It shows how you can use this framework to generate a basic CRUD (Create/Read/Update/Delete) application.

What you need for this book

This is a developer's guide; for this reason, it is highly recommended that you read this book with a computer beside you, where you can try the examples and open, compile, and test the provided projects. Besides this, it's also required that you have an Internet connection where you can download the core server and additional libraries used in the examples.

Good programming skills are required to easily understand the examples presented in this book. Most of the chapters complement the covered topics with a set of executable Maven projects. A basic understanding of Maven, Java, and JUnit is also required.

Who this book is for

If you are a Java architect or a developer who wants to get the most out of the latest release of the JBoss Application Server, this book is for you. You are not expected to have accumulated a lot of experience on the application server, though you must know the basic concepts of Java EE.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text are shown as follows: "The users are stored in a properties file called mgmt-users.properties under standalone/configuration or domain/configuration depending on the running mode of the server."

A block of code is set as follows:

@WebServlet("/test")
public class TestServlet extends HttpServlet {       
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    out.println("Hello World JBoss AS 7");
    out.close();
  }
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {     
  }

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

@SessionScoped
@Named
public class TheatreBookerBean implements Serializable {
}

Any command-line input or output is written as follows:

mvn install jboss-as:deploy –Dhostname=localhost –Dport=9999

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on Finish to continue."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors .

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.