New York
University
Computer
Science Department
Courant
Institute of Mathematical Sciences
Session 3:
EJB-Based MOO Framework Installation Instructions
Course Title: XML for Java Developers Course
Number: g22.3033-002
Instructor: Jean-Claude Franchitti Session: 3
Use
the properly configured example server under Win2000.
1)
Extract
the EJB-MOO.zip file within C:\bea\wlserver6.0sp1\samples\examples\ejb\basic
directory, so that C:\bea\wlserver6.0sp1\samples\examples\ejb\basic\Chat is
created. All the relevant files are inside the Chat directory.
2)
Open
a DOS prompt and set the environment by running C:\bea\wlserver6.0sp1\config\examples\setExamplesEnv.cmd
3)
Go
to C:\bea\wlserver6.0sp1\samples\examples\ejb\basic\Chat, and build the files
by running build.cmd. NOTE: It might
be necessary to invoke build.cmd twice
due to some compile errors the first time around.
4)
For
the entity beans to work correctly, it is necessary to fist create the table ejbChatUsers in the Cloudscape database,
and (this is very important) in the same instance as that used by the
WebLogic’s examplesServer. To accomplish this, follow these steps, without
taking any shortcuts:
a)
Copy
ejbChatUsersSchema.ddl and createtable.bat in the directory C:\bea\wlserver6.0sp1\samples\eval\cloudscape\data.
b)
Make
sure WebLogic’s examplesServer is not running
c)
Go
to C:\bea\wlserver6.0sp1\samples\eval\cloudscape\data
d)
Invoke createtable.bat
5)
Start
WebLogic example server via the start menu, or by running this file: C:\bea\wlserver6.0sp1\config\examples\startExamplesServer.cmd
6)
Point
your browser to http://localhost:7001/console,
to bring up the configuration console.
7)
Deploy
ejb_basic_Chat.jar that can be found
in .\config\examples\applications.
8)
Always
from the Chat directory, start runs.bat batch
file that creates five different chat rooms.
9)
Start
first client: runc.bat Prof
10)
Start second client: runc.bat Student
11)
Start
more clients: runc.bat nickname
12)
For
further illustrations and examples of BMP and CMP beans, run the administration
program runa.bat.
Entity
beans were used in the following manner. Both a BMP and a CMP bean are
associated with each user of the chat room. The bean has three fields:
|
Field |
Description |
|
Name |
Name
of chat user |
|
AvatarCode |
Integer
code for the avatar of this user |
|
Count |
Number
of times the user has joined the chat room |
Each
of this fields is mapped to a column in the ejbChatUsers table. The mapping is handled programmatically in the
BMP implementation, and specified in the DD XML files in the CMP
implementation.
Each
time a user joins a chat room, the corresponding bean is found using its
primary key, which is the name of the user. If this is the first time that the
user joins the chat room, a new bean is created. Every time a user joins a chat
room, the count field is
incremented. A message indicating how many times this particular user has
joined the chat room is displayed in the user’s text area.
An
administration program is provided within the MOO environment to monitor
the successful deployment of both BMP
and CMP beans. The administrator can choose among a few options, such as: list
all chat users, remove chat user (parameterized by chat user name), find most
frequent chat users, find frequent chat users (parameterized by count value).
Furthermore, additional hardcoded installation tests are run at the end, where
forty beans are created, queried in various forms, and finally removed from the
database.
Generally,
the options from the administrator console are implemented as “finder”
functions in both BMP and CMP implementations.
The
relevant source files are:
|
File name |
Description |
|
ChatUserBMP.java |
Business
methods for this bean that allow to read the values of its fields and
increment the count of times user has joined chat room. |
|
ChatUserBMPHome.java |
Finder
methods for this bean enable locating this bean via various parameterized
queries. |
ChatUserBMPBean.java |
Implementation
heavily relies on JDBC. |
|
ChatUserCMP.java |
Business
methods for this bean that allow to read the values of its fields and
increment the count of times user has joined chat room (same as BMP version). |
|
ChatUserCMPHome.java |
Finder
methods for this bean enable locating this bean via various parameterized
queries (different from BMP version). |
|
ChatUserCMPBean.java |
Implementation
is very easy, because the container manages all the connections with the
database guided by the XML DD file weblogic-cmp-rdbms-jar.xml. |
|
Admin.java |
Thorough
illustrations of both BMP and CMP implementations. |