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

An overview of Java EE and JBoss AS 7


Java EE (formerly called J2EE) embraces a standard set of technologies for server-side Java development. Java EE technologies include servlets, Java Server Pages (JSPs), Java Server Faces (JSF), Enterprise JavaBeans (EJBs), Context Dependency Injection (CDI), Java Messaging Service (JMS), Java Persistence API (JPA), Java API for XML Web Services (JAX-WS), and Java API for RESTful Web Services (JAX-RS), among others.

Several commercial and open source application servers exist that allow developers to run applications compliant with Java EE; JBoss AS is the leading open source solution adopted by developers and, although this is difficult to measure in exact terms, it is likely to be the most widely used application server in the market.

Tip

JBoss AS, the most used application server – myth or fact?

We just threw the stone so we cannot avoid discussing it. There is a common belief that JBoss AS is the favorite application server of developers. Actually, there is no empiric way to measure the popularity of open source software; you may be able to guess it from a number of clues such as the number of downloads and the amount of registered users in the community.

Evaluating each product's community statistics can however be misleading and maybe not even be available to all players in this market. Therefore, if we want to try an approximate comparison, let's move to a neutral field where the world's most used software—Google—rules. A one-minute search on Google trends that includes as search keywords the other big players (Oracle WebLogic, IBM WebSphere, and the open source GlassFish application server) reveals that JBoss AS has the highest trend for 2012 at the time of writing. For more information on this, visit http://www.google.com/trends/?q=jboss,oracle+weblogic,+websphere,glassfish&ctab=0&geo=all&date=2012&sort=0. We will get similar results if we query for 2011.

Another popular instrument of Google is Adwords ; it is used to count the search keywords on a national/worldwide basis. Adwords reveals that JBoss accounts for 1.220.000 monthly searches on Google while WebSphere stops at 1.000.000, Oracle WebLogic stays at 823.000, and Glassfish is around 368.000.

So, although these numbers do not provide the last word on our question (nor do they speak about the quality of the product), they are a good indicator of the developer's sentiment. A word to the wise is enough!

As with all application servers compliant with Java EE, JBoss ships with all the required libraries to allow us to develop and deploy Java applications that comply with Java EE specifications.

Welcome to Java EE 6

Java EE 6, includes several improvements and additions to the specification. The following sections list the major improvements to the specification that are of interest to enterprise application developers.

JavaServer Faces (JSF) 2.0

Java EE 6 includes a new version of JSF. JSF 2.0 includes the following new notable features:

  • JSF 2.0 adopts Facelets as an official part of the specification. Facelets are an alternative view technology based on pure XML templates that was introduced with Version 2 of the JSF standard. Some of the advantages of Facelets include the ability to define a view in XHTML, the ability to easily create templates, and the ability to develop JSF components using markup, without having to use any Java code.

  • JSF 2.0 also includes the ability to replace XML configuration elements with annotations, thus greatly speeding up the development of the applications.

Enterprise JavaBeans (EJB) 3.1

EJB 3.1 was designed around the concept of ease of development for users. Now designing an EJB application is much easier and less error-prone than in the past. Some enhancements provided with this application are as follows:

  • Local interfaces are now optional as an actual bean instance and can be injected into local clients. Singleton session beans can be used to manage application states. Session beans can now be invoked asynchronously, allowing us to use session beans for tasks that were previously reserved for JMS and message-driven beans.

  • The EJB timer service of the enterprise bean container enables you to schedule timed notifications for your EJBs. You can schedule a timed notification to occur according to a calendar schedule either at a specific time or at timed intervals.

Finally, Enterprise JavaBeans can now be packaged inside a Web ARchive (WAR) file. This feature greatly simplifies EJB packaging, as in the past an Enterprise ARchive (EAR) file was needed to package web functionality and EJB functionality into a single module.

Java Persistence API (JPA) 2.0

JPA was introduced as a standard part of Java EE in Version 5 of the specification. JPA was intended to replace entity beans as the standard object-relational mapping framework for Java EE. JPA adopted ideas from third-party object-relational frameworks such as Hibernate and JDO and made them part of the standard.

JPA 2.0 improves on JPA 1.0 in a number of areas:

  • It provides transparent support for bean validation (JSR-303)

  • It provides enhanced collection support with the introduction of the @ElementCollection and @OrderColumn annotations

  • JPA queries can now be built through the new Criteria API, reducing the reliance on JPQL

  • The JPA Query Language (JPQL) has improved; it allows adding support for SQL-like CASE expressions, and NULLIF and COALESCE operators

Contexts and Dependency Injection for Java

Contexts and Dependency Injection (CDI) (JSR 299) defines a set of services for the Java EE environment that makes applications much easier to develop. CDI leverages a simpler integration between the Web (JSF) and business logic (EJB) tiers, resulting in a significantly simplified programming model for web-based applications; it also provides a programming model suitable for rapid development of simple, data-driven applications. This is a domain where Java EE has been perceived as overly complex in the past.

Java Servlet API 3.0

Java Servlets API 3.0 provides easier web application development with enhanced annotations and integrated Web 2.0 programming model support, security enhancements, asynchronous support, pluggability, simplified configuration, and other improvements.

Java API for web services (JAX-RS and JAX-WS)

Java EE 6 has adopted JAX-RS as an official part of the Java EE specification. JAX-RS is a Java API for developing RESTful web services. A RESTful web service exposes a set of resources that identify the targets of the interaction with its clients. Resources are identified by URIs; they provide a global addressing space for resource and service discovery.

Java API for XML-based web services (JAX-WS)

JAX-WS is the Java API for XML-based web services. JAX-WS is used to develop traditional SOAP-based web services. Java EE 6 includes an updated JAX-WS specification.

Java architecture for XML Binding (JAXB) 2.2

JAXB provides improved performance via new default marshalling optimizations. JAXB defines a programmer API for reading and writing Java objects to and from XML documents, thus simplifying the reading and writing of XML via Java.