Chapter 1: A Brief Overview of Design Patterns

In chapter 1 we present an overview of what design patterns are by sharing a short history of design patterns and why they are so important to know and use. We continue by talking about the use of design patterns in the real world.

As the main focus of this book we spend a little time on the history and evolution of Java Enterprise Edition so far and how the emergence of enterprise patterns have influenced the way we develop.  Java EE design patterns have evolved substantially in the enterprise environment.

We finish the chapter by discussing the ‘why and how’ of patterns become anti-patterns.

Professional Java EE Design Patterns

Advertisements
Chapter 1: A Brief Overview of Design Patterns

Chapter 2: The Basics of Java EE

In chapter 2 we introduce you to the core concepts of Java EE, such as context dependency injection, convention over configuration and interceptors, that are necessary to know in order to make the best of this book.

We finish the chapter with a discussion of the multi-tier structure of an enterprise application and an explanation of Java EE–compliant servers and the web profile.

Professional Java EE Design Patterns

Chapter 2: The Basics of Java EE

Chapter 3: Façade Pattern

In this chapter we introduce the intent of the façade pattern with a brief discussion of the benefits that the implementation of this pattern brings.

We continue by discussing three ways that the pattern can be implemented: POJO, stateless and stateful session bean façade and the important differences between the stateful and stateless session bean façade.

The chapter ends with a discussion of when and where to use this pattern and warnings about its use and potential pit-falls.

Professional Java EE Design Patterns

Chapter 3: Façade Pattern

Chapter 4: Singleton Pattern

In this chapter we will examine the different ways that a developer can implement the singleton design pattern, its common usage and pitfalls. We start by using static members and methods and demonstrate the problems this causes in multi-threaded environments.

We will see the advances that were made in Java SE 5 with the introduction of the enum type and how it can be used to create thread safe singletons. Then we will discuss the use of the @Singleton annotation in Java EE and how this has radically changed the way we implement the singleton pattern in session beans.

We will introduce the use of BEAN and CONTAINER managed concurrency and we will see how the use of the @LockType annotation controls access to business methods. We finish the chapter with a discussion of the main issues that have dogged the singleton pattern and why it is considered an anti-pattern and has fallen out of favour.

Professional Java EE Design Patterns

Chapter 4: Singleton Pattern

Chapter 5: Dependency Injection and CDI

In this chapter we introduce the concept of dependency injection and why it is so important in Java EE. The we go on to show how to implement dependency injection in Java SE.

We continue by discussing how dependency injection is implemented in Java EE and introduce context dependency injection by discussing the key differences between context dependency injection and the enterprise Java bean container.

Professional Java EE Design Patterns

Chapter 5: Dependency Injection and CDI

Chapter 6: Factory Pattern

In this chapter we discuss what the factory pattern is and why you need it.

How to implement the various flavours of the factory pattern: the factory method and the abstract factory and how to implement the factory pattern in Java EE using the @Producers and @Inject annotations.

We finish by discussing how to create custom annotations and how to use the @Qualifier annotation to disambiguate concrete implementations.

Professional Java EE Design Patterns

Chapter 6: Factory Pattern

Chapter 7: Decorator Pattern

In this chapter we discuss how to implement the decorator pattern in Java SE and how the decorator pattern solved a real‐life dilemma.

We show how to implement the decorator pattern using the @Decorator and @Delegate annotations and how to use qualifiers to gain fine‐grain control over how decorators are used.

Finally we discuss how to make the decorator pattern pluggable via the deployment descriptors

Professional Java EE Design Patterns

Chapter 7: Decorator Pattern