Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
EJB 3 Developer Guide
EJB 3 Developer Guide

EJB 3 Developer Guide: Enterprise JavaBean 3 - a Practical Book and eBook Guide for developers and architects using the EJB Standard.

eBook
$23.39 $25.99
Paperback
$43.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

EJB 3 Developer Guide

Chapter 1. Introduction to the EJB 3 Architecture

In this chapter we will give an overview of EJB 3 and how it fits into the Java EE multi-layer framework. We will also look at installing and getting started with the GlassFish container. The topics covered are:

  • An overview of Java EE

  • The EJB 3 Architecture

  • Getting Started with GlassFish

Introduction to the Java EE Architecture

Modern enterprise applications have their responsibilities divided over a number of layers. A common architecture is the 3-layer model consisting of presentation, business, and database layers. The presentation layer is responsible for presenting a user interface and handling interactions with the end user. The business layer is responsible for executing business logic. The database layer is responsible for storage of business data; typically a relational database management system is used for this layer. Layering is used throughout computer science for managing complexity where each layer serves a distinct purpose.

Java Platform Enterprise Edition (Java EE) technology provides services to enterprise applications using a multi-layer architecture. Java EE applications are web-enabled and Java based, which means they may be written once and deployed on any container supporting the Java EE standard. An application server is the environment in which the container resides. However, in practice we don't need to distinguish between an application server and a container, so we will use the terms interchangeably. The Java EE specification is supported by commercial vendors such as Sun, IBM, Oracle, BEA Systems as well as open-source ventures such as JBoss.

Java EE presentation layer technologies include servlets, JSP pages, and JSF components. These are developed for a business application then subsequently deployed and run in a web container. A client would interact with the web container either from a browser or an applet. In either case the http or https internet protocol would be used for communication.

Enterprise JavaBeans version 3 (EJB 3) is the technology Java EE version 5 (Java EE 5) provides for the business layer. In Java EE 5 we subdivide the business layer into one layer which is concerned with business processing and a second layer which deals with persistence. In EJB 3 the business processing artifacts are session and message-driven beans. These are developed for a business application and deployed and run in an EJB container. The persistence layer artifact is an entity; this is persisted to the database layer using a persistence provider or persistence engine. The persistence engine implements another specification, the Java Persistence API (JPA). Both EJB 3 and the JPA are specifications for which a number of organizations provide implementations. Both specifications can be downloaded from http://www.jcp.org/en/jsr/detail?id=220. The figure below summarizes Java EE 5 architecture:

Note that our 3-layer model has become 5-layers. The distinction between client/web and business logic/persistence layers is not always made. Consequently we refer to Java EE architecture simply as n-layer or multi-layer. A Java EE container offers many other services such as web services, the Java Messaging Service (JMS), and resource adapters.

Note from the diagram that we can access an EJB directly from a Java SE application, such as Swing, without going through a web container. The Java application can be stand-alone, or can be run from an Application Client Container (ACC). An ACC enables a client executing in its own Java Virtual Machine (JVM) outside the EJB container to access a limited number of Java EE services.

Introduction to the Java EE Architecture


Modern enterprise applications have their responsibilities divided over a number of layers. A common architecture is the 3-layer model consisting of presentation, business, and database layers. The presentation layer is responsible for presenting a user interface and handling interactions with the end user. The business layer is responsible for executing business logic. The database layer is responsible for storage of business data; typically a relational database management system is used for this layer. Layering is used throughout computer science for managing complexity where each layer serves a distinct purpose.

Java Platform Enterprise Edition (Java EE) technology provides services to enterprise applications using a multi-layer architecture. Java EE applications are web-enabled and Java based, which means they may be written once and deployed on any container supporting the Java EE standard. An application server is the environment in which the container resides. However, in practice we don't need to distinguish between an application server and a container, so we will use the terms interchangeably. The Java EE specification is supported by commercial vendors such as Sun, IBM, Oracle, BEA Systems as well as open-source ventures such as JBoss.

Java EE presentation layer technologies include servlets, JSP pages, and JSF components. These are developed for a business application then subsequently deployed and run in a web container. A client would interact with the web container either from a browser or an applet. In either case the http or https internet protocol would be used for communication.

Enterprise JavaBeans version 3 (EJB 3) is the technology Java EE version 5 (Java EE 5) provides for the business layer. In Java EE 5 we subdivide the business layer into one layer which is concerned with business processing and a second layer which deals with persistence. In EJB 3 the business processing artifacts are session and message-driven beans. These are developed for a business application and deployed and run in an EJB container. The persistence layer artifact is an entity; this is persisted to the database layer using a persistence provider or persistence engine. The persistence engine implements another specification, the Java Persistence API (JPA). Both EJB 3 and the JPA are specifications for which a number of organizations provide implementations. Both specifications can be downloaded from http://www.jcp.org/en/jsr/detail?id=220. The figure below summarizes Java EE 5 architecture:

Note that our 3-layer model has become 5-layers. The distinction between client/web and business logic/persistence layers is not always made. Consequently we refer to Java EE architecture simply as n-layer or multi-layer. A Java EE container offers many other services such as web services, the Java Messaging Service (JMS), and resource adapters.

Note from the diagram that we can access an EJB directly from a Java SE application, such as Swing, without going through a web container. The Java application can be stand-alone, or can be run from an Application Client Container (ACC). An ACC enables a client executing in its own Java Virtual Machine (JVM) outside the EJB container to access a limited number of Java EE services.

The EJB 3 Architecture


The EJB 3 architecture offers a standard for developing distributed, object-oriented, component-based business applications. The components developed in an EJB framework are session and message-driven beans. Collectively these are known as EJBs. These are usually relatively coarse-grained objects encapsulating a business process. They are components in the sense that EJBs can be combined to create a business application. Furthermore if the EJBs have been well designed they can be reused by another application. EJBs are distributed in the sense that they can reside on different computer servers and can be invoked by a remote client from a different system on the network.

A session bean must have a business interface, which can be either remote or local. A remote client invokes the remote interface of a session bean as shown in the following diagram:

However a session bean and its client may reside in the same JVM instance. In such cases the client invokes the local interface of the session bean. The following diagram shows a web container client invoking the session beans local interface:

A message-driven bean is an asynchronous recipient of a JMS message. The client, which can be a Java application or Java EE component such as a session bean, sends a JMS message to a message queue or topic. The message queue or topic may be managed by a Java EE container or alternatively by a dedicated JMS sever. The following diagram shows a client sending a JMS message which is received by a message-driven bean:

EJBs are deployed and run in a container which is designed to make applications scalable, multi-user, and thread-safe. An EJB container also provides a number of services that an enterprise scale business application is likely to need. We will list these services in the next section.

In contrast to session and message-driven beans, entities are relatively fine-grained objects which have a relatively long life and need to be persisted. Prior to EJB 3, entity beans played the role of entities and were defined as remotely accessible components, like session and message-driven beans. In EJB 3 entities are Java objects and so can utilize object-oriented features such as inheritance and polymorphism, which entity beans could not. In EJB 3, entities are persisted by a persistence provider or persistence engine implementing the JPA specification. This persistence engine can run within an EJB container or outside a container where a business application does not require other EJB services.

Strictly speaking EJBs, being remotely accessible components, include only session and message-driven beans and not entities. However, whenever we refer to EJBs we will in general include entities, unless the specific context requires us to make a distinction. When we refer to EJB components, we mean session and message-driven beans and not entities.

EJBs being Java-based may be written once and deployed on any application server supporting the EJB standard.

EJB Container Services

An EJB container provides a large number of services and we will list a few of these here. Much of this book describes some of these services in detail, in particular those which a business application is likely to invoke.

EJB containers support concurrency and all EJB components are thread-safe. EJB containers provide pooling for EJB component instances. Pooling, in particular, contributes to the scalability of the EJB architecture. We will discuss pooling for session beans in Chapter 2 and for message-driven beans in Chapter 8. Load balancing and clustering are EJB container services which also contribute to the scalability of EJB.

EJB containers provide a naming service, the Java Naming and Directory Interface (JNDI), for accessing EJBs or any other container-managed resource such as JMS queue connections. In EJB 3 a simpler annotation-based dependency injection facility is available which in many cases provides an alternative to JNDI. All EJB 3 containers support Java RMI-IIOP (Remote Method Invocation run over Internet Inter-Orb Protocol), which enables a session to be remotely accessed by a client. A client does not need to know whether the invoked EJB is remote or local, residing in the same JVM. This feature is known as location transparency.

Business systems are often transactional and EJB provides a container-managed transaction service. This is described in Chapter 7.

EJB supports messaging by providing JMS-based message-driven beans. We will discuss message-driven beans in Chapter 8.

EJB provides a basic scheduling capability: the Timer service, which is described in Chapter 9.

A new feature of EJB 3 is the Interceptor service. This allows common, tangential aspects of EJB components to be separated from any business logic. This concept is based on AOP (Aspect Oriented Programming) and is described in Chapter 10.

EJB allows you to convert a stateless session bean into a web service; this is covered in Chapter 11.

EJB provides standards for both the authentication and authorization aspects of security. Authentication is concerned with validating the identity of a user. Authorization is concerned with controlling a user's access to an application, or part of an application. We have covered security in Chapter 12.

Last, but certainly not the least, most business applications need a service for persisting entities. In EJB 3 this service is delegated by the container to a Java Persistence API (JPA) persistence engine.

The JPA Persistence Engine

Many applications do not require the services provided by an EJB container but still need persistence services. For this reason JPA has been issued as a separate specification and applications running outside an EJB container can also make use of JPA services. The main services include:

  • Entity Manager

  • Object/Relational Mapping

  • The Java Persistence Query Language (JPQL)

The Entity Manager provides services for persistence, transaction management, and managing the lifecycle of entities. Object/Relational metadata annotations are provided for mapping entities onto relational database tables. JPQL is used for retrieving persisted entities. We will look at these in more detail in the forthcoming chapters.

Although the JPA specification is recent, it leverages object/relational mapping technology associated with products such as Hibernate and Oracle Toplink. These products have been available for many years; in the case of Toplink for over a decade. The JPA specification drew heavily on these two products in particular. Furthermore, Toplink and Hibernate are the actual default persistence engines for a number of EJB 3 containers. For example, both Sun's GlassFish container and Oracle Application Server 11g use Toplink as the embedded persistence engine. The JBoss EJB 3 container uses Hibernate as the embedded persistence engine. These are pluggable defaults however, so it is possible to use Hibernate with GlassFish for example.

EJB 3 Compared with Earlier Versions

The main features introduced in EJB 3 can be summarized as:

  • Simplified Persistence API

  • Metadata Annotations

  • Improved Query Language

  • Use of Defaulting

  • Dependency Injection

  • Simplification of Session Beans

The first two features are probably the most important, but we will expand on each of the above features in this section.

The main difference between EJB 3 and EJB 2.x is the handling of persistence which we have already outlined. Prior to EJB 3 there was rather limited object/relational mapping between entity beans and relational tables. Inheritance and polymorphism were not possible prior to EJB 3. An EJB 3 entity is truly a Java object; this could not be said of an entity bean.

The other main EJB 3 innovation is the introduction of metadata annotations. Metadata annotations were first introduced in Java SE 5, so this version of Java or higher must be used when developing EJB 3 applications. Metadata annotations can be used as an alternative to XML deployment descriptors both for configuring EJB components and specifying object/relational mappings with entities. However, deployment descriptors can be used in both cases. We will look at annotation versus deployment descriptor aspects in Chapter 2.

The EJB Query language (EJB QL) available in earlier versions was rather limited in comparison with JPA's JPQL. In particular JPQL provides the following enhancements:

  • Projections

  • GROUP BY and HAVING clauses

  • Joins

  • Subqueries

  • Dynamic Queries

  • Queries with parameters

  • Bulk update and delete operations

Extensive use of defaults is made in EJB 3. So, for example, most metadata annotations do not require elements or parameters to be specified, the default is usually common, expected behavior. Annotation elements are usually needed only when we want to configure exceptional behavior.

Dependency injection, first featured in the Spring framework, has been introduced in EJB 3 as an alternative to JNDI for looking up container-managed resources.

Session beans have been simplified. We no longer need to specify component and home interfaces. Furthermore the session bean class no longer has to implement a number of callback interfaces even when these are not required by the application. In EJB 3 these lifecycle callback methods are implemented by session beans only when required.

Getting Started


For this book GlassFish was downloaded on Windows XP and all the examples were run on that platform. The instructions that follow assume a Windows platform is being used, however the installation instructions for other platforms such as Linux/Unix are almost the same.

Installing GlassFish

Before installing GlassFish check that version 5 or higher of the Java Development Kit (JDK) is present on your workstation. This can be downloaded from

http://java.sun.com/javase/downloads/index.jsp

For this book we used JDK 5.0 Update 12.

Set the environment variable JAVA_HOME to point to the directory in which the JDK is installed. Add %JAVA_HOME%\bin, to the PATH environment variable. This is done by clicking Control Panel from the Start menu. Then double-click the system icon. Select the Advanced tab on the System Properties box. Finally click the Environment Variables button.

Next download a version of GlassFish equal to or higher than V2b41d from:

https://glassfish.dev.java.net//

into the directory in which you want to install it. All the code examples in this book were tested with GlassFish version V2b41d. The actual name of the downloaded jar file will depend on the version and platform selected. For this book glassfish-installer-v2-b41d.jar was used. In the same directory as the downloaded jar file, run the jar file as follows:

java -Xmx256m -jar glassfish-installer-v2-b41d.jar

This will unzip the file and create the glassfish subdirectory.

Set the GLASSFISH_HOME environment variable to the directory where GlassFish was installed. Add %GLASSFISH_HOME%\bin to the PATH environment variable.

Set the environment variable ANT_HOME to the directory in which Ant is installed. GlassFish comes bundled with the Ant build tool and the installed Ant directory will be glassfish\lib\ant.

If you already have a version of Ant equal to higher than 1.6.5 then set ANT_HOME accordingly.

Add %ANT_HOME%\bin to the PATH environment variable.

Change the directory to the glassfish directory and complete the installation by running the Ant setup script:

ant -f setup.xml

The setup process may fail because of port conflicts with existing software you may have. If so you will need to edit the setup.xml file. Within the file you should see the following fragment setting up default properties:

.....
<property name="domain.name" value="domain1"/>
<property name="instance.name" value="server"/>
<property name="admin.user" value="admin"/>
<property name="admin.password" value="adminadmin"/>
<property name="admin.port" value="4848"/>
<property name="instance.port" value="8080"/>
<property name="orb.port" value="3700"/>
<property name="imq.port" value="7676"/>
<property name="https.port" value="8181"/>
<property name="glassfish.license" value="LICENSE.txt"/>
....

Change the value for the conflicting port, and run setup again.

Testing the Installation

GlassFish is started with the following command:

asadmin start-domain domain1

You should see the following messages:

In particular this shows the admin console URL and the URL for web applications. So enter the URL http://localhost:8080 from a browser. If GlassFish has started up correctly you should get the following page:

Accessing the Administrator Console

Enter the URL http://localhost:4848 from a browser. You should get the following page:

The default user name is admin and the default password is adminadmin. After you have entered these you should get the following page:

The administrator console is used for numerous tasks such as creating and configuring domains, monitoring performance, and deploying applications. An alternative for deploying applications is using the asadmin tool from the command line.

In the remainder of this book we have used the asadmin tool for deployment. By including it as an Ant target the whole process of compiling, packaging, and deploying is automated.

Shutting Down GlassFish

To stop GlassFish use the following command:

asadmin stop-domain domain1

Downloading Example Source Code

The source code for the examples can be found as a zip file on the book's web site. Download the file and unzip it into a drive and directory of your choice. The examples in the book assume the source code has been downloaded into the C:\ directory. Subdirectories correspond to individual chapters: C:\EJB3Chapter02, C:\EJB3Chapter03, and so on. You should consult the readme file before running any scripts.

Summary


We gave an overview of the EJB 3 architecture and its relationship to the multi-layer Java EE architecture. EJB technology applies to the business processing and persistence layers of the multi-layer model. There are three main artifacts a business application using EJB technology will develop: session-beans, message-driven beans, and entities.

These artifacts are deployed to an EJB container which provides a number of services. We had a brief look at some of these services. In particular we saw that a separate service, the Java Persistence API, is provided for persisting entities.

Finally we saw how to get started with Sun's open-source GlassFish EJB 3 container. All the examples which follow in this book have been deployed and run on GlassFish.

In the following chapter we will look at developing the EJB component which handles business processing, namely session beans.

Left arrow icon Right arrow icon
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 23, 2008
Length: 276 pages
Edition :
Language : English
ISBN-13 : 9781847195609
Category :
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Publication date : May 23, 2008
Length: 276 pages
Edition :
Language : English
ISBN-13 : 9781847195609
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 144.97
Mastering Spring Boot 3.0
$39.99
EJB 3.0 Database Persistence with Oracle Fusion Middleware 11g
$60.99
EJB 3 Developer Guide
$43.99
Total $ 144.97 Stars icon

Table of Contents

12 Chapters
Introduction to the EJB 3 Architecture Chevron down icon Chevron up icon
Session Beans Chevron down icon Chevron up icon
Entities Chevron down icon Chevron up icon
Object/Relational Mapping Chevron down icon Chevron up icon
The Java Persistence Query Language Chevron down icon Chevron up icon
Entity Manager Chevron down icon Chevron up icon
Transactions Chevron down icon Chevron up icon
Messaging Chevron down icon Chevron up icon
EJB Timer Service Chevron down icon Chevron up icon
Interceptors Chevron down icon Chevron up icon
Implementing EJB 3 Web Services Chevron down icon Chevron up icon
EJB 3 Security Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2
(6 Ratings)
5 star 50%
4 star 33.3%
3 star 0%
2 star 16.7%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Jimminy Zappadoowah Dec 29, 2008
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Trimming down the typical EJB 3 guides and documentation out there did not seem to be the goal of the author. However, he did so by trimming all the fluff out of the book and presenting things in an organized, succinct manner that prove he took his time while writing the text.Possibly what I enjoyed most about this book was the fact that the author took the time to carefully choose each word he used. This resulted in a clear understanding without rambling or going off-point as even the EJB 3 books published from O'Reilly do (of which I am a supporter). The sheer clarity and careful nature of the author really shines through and makes it a fast, easy reader from beginner to advanced offering your much more clarity than any other book it currently competes with.Well organized as well, this book presents EJB 3 development using concrete examples and in a logical, real-world order. Many of its competitors use a very academic approach, which is good for reference, but lack this author's obvious understanding of solving a real-world solution from the ground-up. The book's author has written and organized the text in such a way that you won't find yourself doing a lot of rework and/or revisiting to pieces of code as much as you find in other books which makes for a much clearer picture of how EJB 3 can be applied to your specific problem domain.Simple illustrations/diagrams make things easy to follow as well. The author, again, took the time to create simple but meaningful designs for this information rather than relying on flashy graphics or over-done diagrams to attract your attention (as I am sure we have all seen in many company presentations, lectures, etc. etc. etc.). This allows for easy explanation not only to the reader, but also provides the reader with succinct, clear examples of implementation and strategy that can be taken to decision makers that are a step above development and/or architecture.The book also focuses on very generic solutions. This allots the user with the ability to research the wide variety of options available to them in the EJB 3 and J2EE world. While not directly stated in the book, it does, in fact, list many key points to use while evaluating the pieces to the puzzle that you use for completing your EJB 3 solution as well as touching on points that cover "is EJB 3 really right for my problem?".Overall: Extremely impressive. Less of a reference and more of a front-to-back walk-through. Despite that, it is valuable for all to read from not even knowing what EJB 3 actually is to working with the solution in your day-to-day professional career.I look forward to more titles from the author and, immediately after completing this review, will be searching Amazon.com for some to purchase on other topics of interest. Huzzah to the author for a wonderful text.
Amazon Verified review Amazon
Indikos Dec 14, 2008
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The stated purpose of this book is to serve as a tutorial. In that it succeeds extremely well. Within a week of reading this book I was a competent EJB developer. The book is very focused, it also engages the mind and keeps one going. Of course it is not comprehensive - for that one should get the Panda book.
Amazon Verified review Amazon
Robert Daniels Jun 07, 2009
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I've been developing Java for several years, but have not used or required Enterprise JavaBeans until recently. I first purchased the O'Reily book, "Enterprise JavaBeans 3.0", but before reading it, stumbled upon the PACKT Publishing book, "EJB 3 Developer Guide". Michael Sikora has an excellent writing style. I won't go into the chapter by chapter iteration that some of the other reviewers have done so well, but you get an excellent and rapid start on learning EJB, JPA, annotations, etc.If you're a Java developer and want to get up to speed in just a few weeks on EJB 3.0, my suggestion is to purchase both books. Start with "EJB 3 Developer Guide", which you should be able to do in a weekend, or faster if you don't actually run the samples, then move to the in-depth look at EJB with the O'Reilly book. I actually used the O'Reilly book as a reference when I wanted to know more about a certain topic, then went back to the PACKT book as the pace was pretty nice and fast. You then have a good starting point when diving into the second book.
Amazon Verified review Amazon
Kevin Boone Dec 03, 2008
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Books on EJB technology tend to be fairly weighty. There are tomes of over 500pages that deal solely with the persistence manager. And here we have a slim(by EJB standards) volume that claims to offer a complete overview in a mere240-or-so pages including, incredibly, EJB Web Services. Is that possible?Well, up to a point it is. The trick is to focus ruthlessly on the informationneeded to make things work, while skimming over technicalities. The book claimsto provide a `fast-paced tutorial' and that is, I think, exactly the way tolook at it. If you're interested in investigating the possibility of using EJBin a particular project, and know little about the technology, then this bookwould provide a great introduction. It's easy to read, liberally scattered withcode examples, and nicely presented. An experienced Java developer could readit cover-to-cover in a few hours and understand most of it in one reading.That's pretty unusual for a book on this subject.Chapter 1 deals with the EJB architecture (very briefly indeed) and how toobtain and set up the GlassFish application server.Chapter 2 is more meaty, covering session beans and EJB clients. It is notablethat Java annotations are used here and throughout the book -- there is littlereference to the earlier ways of doing things. Knowledge of how annotationswork is assumed -- there is no technical explication. Another simplifyingfactor is the use of client containers to invoke EJB code. This means that theauthor doesn't need to explain in detail how JNDI works, and the reader doesn'thave to try to follow the explanation. But, again, there is a world of detailhere that developers will have to get to grips with at some point.Chapters 3-5 deal with entities, OR mapping, and the query language. Thesesubjects are closely related and the chapters really form a single chunk ofmaterial. There's certainly enough detail here to be able to build astraightforward application.Chapter 6 is a bit of an anomaly. It deals with the entity manager, and issurprisingly technical compared to the preceeding content. That, in itself, isnot unwelcome -- this is a highly technical area. But since a lot of thismaterial is relevant to stand-alone persistent applications, and notspecifically to EJBs, I was rather surprised to find this level of detail atthis stage.Chapter 7 deals with transations and, again, provides enough information to getstarted.Chapter 8 deals with JMS and message-driven beans (MDBs). Little or noknowledge is assumed of JMS and, in fact, only about four pages of this chapteractually deal with MDBs. That's fair enough, I think -- if you have the basicsof JMS under control, MDBs are straightforward enough. But there is only a halfa page on transaction handling in MDBs, which (in my view) isn't enough, evenat an introductory level.Chatper 9 deals with timer services and is pretty clear.Chapter 10 deals with interceptors, which are a new feature in EJB3. Again, thematerial is straightforward and well illustrated with examples.Chapter 11 describes Web Services in the EJB world. I have mixed feelings aboutthis chapter. There's certainly enough information in the chapter that a personwith no experience of Web services could follow the examples. But Web Servicesis a massive area of technology, and I'm not sure it's profitable to try todeal with it in a single chapter. But I'm not sure what the alternative wouldbe, other than leaving it out. It's not a bad chapter, but I think it will bevery difficult to follow what's going on for people who don't have a backgroundin Web services.Chapter 12 is about security, and is pretty straightforward.I think that this book should appeal to developers who are new to EJB, and justwant to get straight to coding, without reading too much theory. In the longterm, any developer who works with EJB extensively is going to have toget to grips with the theory, and the inpenetrable EJB Specification, buta gentle introduction ought to be welcome.In addition, I would recommend the book to experienced EJB2 developers, whospecifically want a rapid introduction to the new features of EJB3.In short, this is a good book and I recommend it; but developers shouldn'tget the idea that this is the only thing they'll ever need to read on thesubject of EJB3.
Amazon Verified review Amazon
W Boudville Dec 07, 2008
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
EJB version 2 became notorious for its sheer unwieldiness. Programming the various session and entity beans was a miserable experience, noted for its complexity and the verbosity of the source code and deployment descriptors. Much better is EJB 3 as Sikora explains.To fully appreciate his book, you should have tried coding EJB 2. But here are the main advantages. There is no entity bean. Instead, we have what are called simply entities. These are Plain Old Java Objects with some extra requirements. Which leads immediately to the idea that an existing java class which is a POJO can be converted to an entity with minor changes. Whereas the EJB 2 entity beans need a remote or local interface and a home or local interface, along with an XML deployment descriptor file. In a similar way, the new EJB 3 session beans can drop the home interface.Another change is the use of Java annotations. These are special lines beginning with "@" that appear in the source code. What these do is let you avoid writing a deployment descriptor file for that java class. Those files are typically longwinded and manually editing them is error prone. The annotations are remarkably concise and a joy to use, by contrast.Granted, some readers might think that annotations look like an ugly kludge and clutter up the source code. But overall, you gain, simply by being able to discard many of the descriptor files. The complexity of maintaining those in tandem with the associated source files can be (and perhaps often is) a cause of bugs.The other big improvement described in the book is the use of an Entity Manager. It hooks up an entity with a database, using java Persistence. And the JPQL aids the mapping to and from the object oriented approach of java to the relational features of SQL databases. Instead of doing the traditional query to the latter and getting back a ResultSet, from which you might to have java objects. The latter involved grubby low level parsing of the ResultSet. Now JPQL lets you think and code at the level of objects. Giving simpler, more robust code.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the digital copy I get with my Print order? Chevron down icon Chevron up icon

When you buy any Print edition of our Books, you can redeem (for free) the eBook edition of the Print Book you’ve purchased. This gives you instant access to your book when you make an order via PDF, EPUB or our online Reader experience.

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
Modal Close icon
Modal Close icon