1. Home
  2. Training Library
  3. Programming
  4. Programming Courses
  5. Using Design Patterns in Java Projects

Business Delegate

Contents

keyboard_tab
Design Patterns
1
Design Patterns
PREVIEW2m 26s
2
Singleton Pattern
PREVIEW3m 13s
9
Decorator
7m 48s
10
Flyweight
9m 20s
11
Proxy
7m 36s
12
Facade
6m 5s
14
Command
11m 44s
15
Iterator
8m 24s
16
Visitor
9m 4s
17
Mediator
11m 38s
18
Memento
9m 48s
19
Observer
10m 40s
20
Strategy
8m 27s
21
State
10m 27s
22
Template
7m 56s
23
MVC
10m 27s
26
DAO
10m 27s
27

The course is part of this learning path

Start course
Overview
Difficulty
Intermediate
Duration
4h 56m
Students
19
Ratings
5/5
starstarstarstarstar
Description

This course takes an in-depth look at how to use design patterns in your Java projects. We will then run through some example questions of what you could expect from the Oracle Certified Java EE exam.

Learning Objectives

  • Understand what design patterns are
  • Learn about the myriad of design patterns that you can use in your projects

Intended Audience

This course is intended for anyone who already has basic knowledge of Java and now wants to learn about Java EE 6.

Prerequisites

Basic knowledge of Java programming.

 

Transcript

Hello, dear friends. In this video, we will examine the Business Delegate pattern. Let's begin. The Business Delegate pattern is one of the core Java EE design patterns. It's used in order to decouple or reduce the coupling between the presentation tier in business services. It's also required to hide the details of the implementation of the services, meaning it's needed to remove the function of lookup in the business tier code with the presentation tier code. It's basically used to reduce communication or remote lookup functionality to business tier code in presentation tier code. The Business Delegate pattern adds an abstraction layer between presentation and business tiers. By using the pattern, we gain loose coupling between the tiers and encapsulate knowledge on how to locate, connect to and interact with the business objects that make up the application.

As you can see, in the UML of iterator, there are three participants. BusinessDelegate is a single-entry point class for client entities to provide access to BusinessService methods. The BusinessService is a business tier component, such as an enterprise bean or a JMS component that provides the required service to the client. The BusinessDelegate uses the lookup service to locate the BusinessService. The lookup service encapsulates the implementation details of BusinessService lookup. The BusinessDelegate's role is to provide control and protection for the BusinessService. The BusinessDelegate can expose two types of constructors to clients. One type of request instantiates the BusinessDelegate without an ID while the other instantiates it with an ID where ID is a string version of the reference to a remote object such as EJBHome or EJBObject.

When initialized without an ID, the BusinessDelegate requests the service from the lookup service typically implemented as a service locator which returns the service factory such as EJBHome. The BusinessDelegate requests that the service factory locate, create, or remove a BusinessService such as an enterprise bean. BusinessDelegate reduces coupling between presentation-tier clients and BusinessServices. The BusinessDelegate hides the underlying implementation details of the BusinessService. Now, let's create a project using the Business Delegate pattern. Create a new project and name it BusinessDelegate. First, we need a BusinessService as interface. We will define the process method. Afterwards, let's define two concrete classes implementing this interface. EJB. We will override method. Now, JMS. Override for JMS. Let's define a lookup service. The lookup service object should provide the relative business implementations and business object access to the BusinessDelegate logic.

Now, we can define our BusinessDelegate. Also, we need a client to act as an access point to the BusinessServices. Let's use this pattern. First, define delegate. Now, send EJB to service. Now, set delegate to client. Change with JMS. Done. Let's look at the result. First process is EJB and the second one is JMS. We have now finished examining this pattern. In the next video, we will look into the Composite Entity Pattern. See you in the next video.

 

About the Author
Students
413
Courses
35
Learning Paths
2

OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.

Covered Topics