程序代写代做代考 Java Note on How to Run the Example Code

Note on How to Run the Example Code
The zipped projects demonstrate how the different JEE components inter-play.
It contains a web UI, application logic. The application logic are implemented in different projects, according to the nature of the business.
There are three projects: 1. CourseWeb
2. CourseJMS
3. CourseWS
The application logic is as follows:
A student registers for three courses via a website (CourseWeb). The website:
– Sends the registration request to the application (CourseJMS) managed by another department, e.g., by Study-Admin.
– Searches for names of the teachers of the requested courses and the course schedules.
– The schedule is managed by another application (CourseWS) owned by a different
department and, e.g. Kronox.
CourseWeb
JMS
Browser
Show
1. RegisterPage
2. RegServlet
CourseJMS
RegMessage: Message Driven Bean to Read from Queue
YourQueue
Reg Reg Reg
Web-tier
JSP: Register.JSP Servlet: RegServlet.java
App-tier (Beans) TeacherBean.java
ScheduleBean.java
CourseWS
CourseSchedule.java

The application flow is as follows:
Web-tier
1. A client calls a JSP called RegisterPage.jsp a dynamic web page in CourseWeb to request
the student to enter registration details.
2. The JSP sends the registration information entered by the student to a servlet called
RegServlet. 3. The servlet
a. notifies the CourseJMS that a registration request has arrived. The servlet places the data in a queue (called YourQueue) accessed by CourseJMS
b. makes calls to two EJB session beans (called TeacherBean and ScheduleBean) to get information about teachers and course schedules.
c. returns the response it received from the beans to the client browser. *
Application-tier **
4. EJB bean TeacherBean has only one bean method which has only one argument (CourseID). It performs some ‘operation’ on the courseID and returns the name of the teacher to RegServlet
5. EJB bean ScheduleBean has only one bean method which has only one argument (CourseID). It calls a web service method in another project to get the schedule and returns the result to RegServlet
6. CourseWS has only one service called CourseSchedule. This service has only one method called getWeekDays(courseID). When called, it returns the week days the course is taught.
7. CourseJMS has only one message driven bean. The bean onMessage() method has only one function. It checks for messages in the queue and displays a message in the Glassfish server to confirm that the registration request is received.
* The reponse to client could have been redirected to another JSP (instead of sending it from the Servlet to the client browser directly).
** In reality the EJB beans may be in a another project/server. The business logic is often run or owned by another business entity (company/department, etc)

Glassfish Administration
You may experience problems creating components in your Glassfish server 4.1.1. (I experienced the problem). In that case you need to run the application server administration utility (asadmin) from the command line.
For more information:
JMS Documentation for GlassFish https://docs.oracle.com/cd/E18930_01/html/821-2416/ablkb.html
0. Start the GlassFish Application Server Administration facility (asadmin) located in the bin directory of your Glassfish installaiton
0.1. Start the command shell (run cmd in the START menu if you have a Windows machine) 0.2. Change directory to your GlassFish Installation directory
cd c:\[your GlassFish Installation Directory\bin]\
0.3. Start the GlassFish Administrator by typing the command: asadmin
You will now be in the GF administrator shell. You can create the JMS objects now.
1. Create connection factory:
create-jms-resource –restype javax.jms.ConnectionFactory –description “connection factory for
Order Processing” –property ClientId=MyID jms/RegConnectionFactory 2. Create Queue in this connection factory:
create-jms-resource –restype javax.jms.Queue –property Name=PhysicalQueue jms/RegQueue The boldface text is the name of your queue and queue connection factories.