Tải bản đầy đủ (.ppt) (34 trang)

Bài giảng Lập trình mạng Entity Bean - GV. Nguyễn Xuân Vinh

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (514.67 KB, 34 trang )

28/05/151 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN

Presenter: Nguyễn Xuân Vinh
Information Technology Faculty
Nong Lam University
28/05/152 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN



Describe the concept of persistence.

Define entity beans.

List the features offered by entity beans.

Compare entity and session beans.

Explain Message-Driven Beans.
28/05/153 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN


In Session 4 we discussed:

Definition of a Stateful Session Bean.


The characteristics of a Stateful Session Bean.

How to program Stateful session beans.

Difference between Stateless and Stateful Session
beans.
28/05/154 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN





 !

"!!#
$





Persistence
Objects


28/05/155 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN



%
&



'!!
 !!"# "$#"
#%
!&%"# '
$
(!##) *(
 +,( 
$

28/05/156 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN
-
"!!#
.(!"")
/$
.,/
)!$)

0
1!%!

)!

##
2"3
1!%!
##*)"
"
28/05/157 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN
4
(

Object database persistence is designed to store Java
Objects as whole objects which means that there is no
need to program a relational database.

The Object Query Language (OQL) provides the
facility to query the persisted objects.

This language adds a layer of abstraction from the
relational database queries.

The EJB QL eliminates the inconsistencies caused due
to the use of the different Query languages used by
different application servers.
28/05/158 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN
5
'!$!$")*(!*
+!!#!

+!!#!!!$$
! 
$#)% #"
%",
!!#*)"
28/05/159 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN
6
'!$!$")*(!*
('!

!&%*
(
7$#!%",
$%)" %",
)$*$)
$#!'*)" !*
#!"+,
28/05/1510 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN

,



-

.

'


'
(!
(!
/
-
0
-
28/05/1511 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN


*!
(
!


#

" $
%'
8%
97$#!:%'"!"$#
!%!!*8%%'"
 "!+!! $#+ !
28/05/1512 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH

TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN

1-
!
%'

0(,
)
 *
)
1$0"
28/05/1513 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN

/-
"
8*
*'
.  $")*' "!":8***'%'
"
!
2
 *
;$
0"
%'
"
%'
"

%'
"
28/05/1514 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN

0-
<"!!
%'

 *
%'

7#
<"!0"!!+ 7#$ *  
*+  $"=!"!"!>

28/05/1515 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN

.'

Primary keys make each entity bean look different.

A primary key is an object itself which contains other
objects and data that is necessary to identify an
entity bean data instance.

The primary key class has to be serializable, and has

to follow the rules of Java object serialization.

The unique identifier, or primary key, enables client
to locate the particular entity bean.
28/05/1516 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN
-
(!(!
'
(!
$!
0
!!
" *#!'$
*"#*#!'$
0$ ") 
*"!
28/05/1517 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN
4
#-


%'

%'

%'


0%




1#
%'
!*
*
1"'"!*
%'

?  "
)*:*
*!*@"!
A)
28/05/1518 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN
5
2

%'

%'$#
 $!( 
*
3$*"
3

*
"
#!'$
"#

(!(!
)!3$
$$$#
28/05/1519 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN
6
2 #

The entity bean instance and the underlying database
can be considered as one and the same.

When the bean-managed persistent bean calls the
ejbCreate() method, it creates the database data.

In case of container-managed persistence, the
container contains required data access logic, leaving
the bean’s methods empty of data access logic.

The finder methods are used to find the existing entity
bean in storage. The finder methods do not create any
new database data, but they load old entity bean data.
28/05/1520 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN


"$#()#
(
'4



5#
+!!
(
4"!!#
((
"$3
$
28/05/1521 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN

(!#$6#

In order to write an entity bean class, the
javax.ejb.EntityBean

interface has to be implemented. It is this interface that defines the
call back method used by the container which the bean must
implement.
* setEntityContext(javax.ejb.EntityContext)
* unsetEntityContext()
* ejbRemove()
* ejbActivate()

* ejbPassivate()
* ejbLoad()
* ejbStore()
28/05/1522 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN

'78

Used to initialize the fields of a bean instance which
can be used for a particular client to create the
underlying database data.

The parameters vary with respect to the ejbCreate()
method. Therefore, there are multiple ways to initialize
an entity bean instance.

The ejbCreate() methods in the home interface have to
be duplicated in the bean class.
28/05/1523 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN

,$78





;$"

"
%'
"
'4
!!"=>
-1)" "!
!!=>
1)#$','
''$
**
"
Creating a BMP EJB and an EJB object
28/05/1524 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN

,$78*)

All finder methods have to begin with “ejbFind”.

There has to be at least one finder method by the name
ejbFindByPrimaryKey(). The method finds a unique
entity bean instance based on the unique primary key.

There can be various finder methods, with different
names and different parameters.

The finder method has to return the primary key for the
entity bean it finds. Other than this, it can also give an
enumeration of primary keys.


The client will never call the finder methods on the
bean instance itself
28/05/1525 /XX
MÔN: LẬP TRÌNH MẠNG 2 GV: NGUYỄN XUÂN VINH
TRƯỜNG ĐẠI HỌC NÔNG LÂM TP.HCM KHOA CÔNG NGHỆ THÔNG TIN

78*-

Called to remove data from the database

The instance of the bean can be recycled to handle data
from a different database

Does not take any parameters

×