Java Reference
In-Depth Information
@Singleton and @Startup annotations to the class and @PostConstruct to the initialization
method. See Chapter 4, “Singleton Pattern,” for a detailed explanation of the use of these
LISTING 2‐1: POJO becomes a container‐managed singleton bean with the addition
of some annotations
package com.devchronicles.singleton;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;
public class CacheSingletonBean {
private Map<Integer, String> myCache;
public void start(){
myCache = new HashMap<Integer, String>();
public void addUser(Integer id, String name){
myCache.put(id, name);
public String getName(Integer id){
return myCache.get(id);
The aim of Java EE has not changed; it continues to recognize the requirement that developers and
enterprises have for distributed and transactional applications that harness speed, security, and
reliability. The Java EE platform is designed to make the production of large‐scale, multitiered
applications easier, more reliable, and more secure.
The architecture of a Java EE application is separated into tiers: the Client tier, the Middle tier
(which consists of the Web layer and the Business layer), and the Enterprise Information Systems
(EIS) tier. Each tier has unique responsibilities and utilizes different Java EE technologies. The
segregation of an application into distinct tiers brings greater l exibility and adaptability. You have
the choice of adding or modifying just a specii c layer rather than refactoring the entire application.
Each tier is physically separate and located on different machines. And in the case of a web
application, the Client tier is distributed globally.
Search WWH ::

Custom Search