Java IoT Authors: Pat Romanski, Elizabeth White, Liz McMillan, Yeshim Deniz, Mehdi Daoudi

Related Topics: Java IoT

Java IoT: Article

E-Business with EJBs

E-Business with EJBs

I expect great things from Enterprise JavaBeans this year, one of which is dominating the e-business front as the component model of choice for server-side application development.

Giving House Calls a New Meaning
E-business is multifaceted, encompassing e-commerce (monetary transactions over the Internet), business-to-business solutions and internal Web-based applications that provide flexibility and innovation in the services companies offer. E-business innovation has improved customer care and fostered repeat business for companies like Amazon.com, Dell and numerous online investment sites, to name a few.

However, early last year I was fascinated by the story a friend told me about her father, a radiologist from Boston, who used e-business technology to provide an extremely valuable solution to his customer, a patient with a fractured leg. During a visit to her home, my friend's father received a request on his cell phone for his opinion on a patient. He logged onto the hospital's Web site with his daughter's laptop and diagnosed the fracture by viewing X-rays over the Web!

This article provides a similar demonstration of the value of e-business above and beyond e-commerce. And if you had any doubts, the e-business solution I provide in this month's EJB Home, Acme HealthCare's e-Patient, is based on the following technologies: Enterprise JavaBeans and Java servlets. E-Patient is by no means industrial strength, but it's been developed with techniques not yet covered in EJB Home, such as EJB Handles and stateful session beans. I'll also provide ideas that I'll address appropriately in a future article on how to improve the application in the areas of robustness and performance.

Acme HealthCare's E-Patient Requirements Overview
The doctors at Acme HealthCare wanted the ability to enter and review patient information - even diagnose patients - by way of the Internet. In particular, doctors who had practices spanning multiple hospitals needed to be able to perform an initial "distributed" diagnosis from one location, then finish the patient assessment once they arrived at the hospital where the patient was located. Two use cases were modeled to cover usage of the e-Patient application (see Figure 1):

  1. Enter Patient Info
  2. Diagnose Patient

In Enter Patient Info the actor is either a nurse or a doctor. He or she enters the patient's history into the Patient Information Form and submits it. The next use case, Diagnose Patient, involves the doctor's entering a diagnosis and submitting it.

If a nurse was the actor in the Enter Patient Info use case, he or she must call the doctor to say that a patient record needs to be reviewed. The doctor who receives the call pulls up the patient record in a browser to make the initial diagnosis, which provides an avenue for others to treat the patient until the doctor arrives.

Acme HealthCare's E-Patient Technical Overview
The Java platform has all the necessary elements to solve the business requirements. The technical solution presented below specifically involves Enterprise JavaBeans with view and controller responsibilities handled in Java servlets. Included in the design are a simple static HTML form (see Figure 2) and a servlet that processes the submitted data. The current design doesn't include a database, but I'll discuss this below, along with other ideas for design improvements.

At the heart of the system is the PatientSessionBean, a session bean that contains patient information and business logic. The bean is deployed as a stateful session bean to allow a client to access it multiple times without losing state between requests. Code for the enterprise bean component is given in Listings 1, 2 and 3 (remote interface, home interface and session bean, respectively).

An interesting feature of a stateful session bean is its ability to be passivated and activated by its container for memory and performance reasons. After a period of time has passed between client calls, the EJB container will store all nontransient, serializable attributes of the PatientSessionBean in some form of temporary persistent storage. This is usually just a file, but could be more robust depending on the container implementation. The next time the client calls the bean, the EJB container will allocate memory for the enterprise bean and service the request, a process called activation. Since the bean instance has been stored, a handle is used to return the bean to the active instance pool. EJB Handle objects are found through the EJBObject interface method getHandle(). Storing Handle objects can be done either persistently through serialization or you can just hold onto them in memory, as seen in Listing 4 of the PatientTrackSessionServlet.

While a session bean isn't meant to live beyond a hardware or software failure, passivation does provide a pseudopersistent environment that allows EJB servers to handle higher volumes of users in a stateful server architecture.

User Interface
The entry point into e-Patient for the nurse actor in Enter Patient Info is the Patient Information Form, a static HTML form for entering information about the patient. When submitted, however, a Java servlet, as indicated in the tag, processes it:

<form method=POST action="http://vergetg1:7001/PatientTrackSessionServlet">

The tag is hard-coded to access my machine, probably not the best idea for a production application, but feel free to download the source code from www.JavaDevelopersJournal.com and modify it to suit your needs.

Once our Web server receives the HTTP request for submission, the PatientTrackSessionServlet processes it by parsing the form parameters and potentially modifying or creating a new PatientSessionBean. PatientTrackSession.java is not listed in full here.

The PatientTrackSessionServlet (see Listing 4) is multithreaded (e.g., a singleton servlet) and uses a hashtable to handle synchronization issues when multiple clients access it concurrently. It uses the hashtable patientCache to hold instances of javax.ejb.Handle, representing currently tracked PatientSessionBeans (active or passivated).

Implementing the Enter Patient Info Use Case
When a nurse or doctor submits the patient information to the system, the PatientTrackSessionServlet takes the patient information from the HttpRequest object, then checks to see if the patient is already entered into the system by checking the patientCache for a valid Handle object. If the patient isn't in the system, a new patient is created with the submitted information, and else use case, Diagnose Patient, is executed (see Listing 4).

Implementing the Diagnose Patient Use Case
In this use case the patient's doctor is validated and the diagnosis is updated. Currently, only the patient's doctor has access to the patient's records. When the patient information is submitted and the patient currently exists, the Handle object referring to the PatientSessionBean is used to get a proxy to the session bean.

patient = (Patient)handle.getEJBObject(); // get EJBObject from handle

If the session bean had been passivated during this time, the container would activate it and return a proxy (EJBObject) of the component. Considering that a valid EJBObject is returned, the diagnosis is updated accordingly when the Web page is submitted.

The stateful session bean solution solves our business requirement of allowing a doctor to enter an initial diagnosis, then return to the patient record to update it once more information is known. The technical implementation of e-Patient is adequate to show some nice features of EJB such as Handles and stateful session beans. There is room for improvement, however. Let's look at some enhancements that could be made to this e-business solution.

Feature Enhancements
Our e-business solution for patient care has a number of areas in its business requirements and technical solution that could be improved. Patient confidentiality and data security are important in health care, so business requirements restricting access to patient records should be better defined. A login process should be implemented to prevent unauthorized users from accessing the system. Likewise, EJB's support of Access Control Lists (ACLs) could be used to restrict access in a role-based manner. For instance, nurses may have the ability to enter patient information but not make a diagnosis.

Also, stateful session beans are perhaps not the best solution for keeping patient records. They should be stored instead in a database to prevent loss of data in the event of a system failure.

Last, servlets are important in a Web-enabled Java application, but JavaServer Pages (JSPs) are increasingly taking precedence over servlet development.

JSPs improve productivity by allowing HTML developers to script the user interface of the application while Java developers plug in Java code where needed. Migrating the servlets in our solution to JSPs would be an evolutionary move toward future productivity gains.

I'll expand this solution in a future article to include some of the new features discussed and cover more interesting areas of EJB in the process.

This month we explored the topic of e-business with Enterprise JavaBeans. We covered EJB Handles, accessing enterprise beans from a servlet and the possibility of designing stateful server architectures based on stateful session beans.

The Java platform provides a foundation to build complex Web solutions. When core business processes become e-business enabled, employees perform their jobs more efficiently, bringing value to other employees, suppliers and customers alike. For example, the added value that an e-business solution brings could be the difference between life and death!

More Stories By Jason Westra

Jason Westra is the CTO of Verge Technologies Group, Inc. (www.vergecorp.com). Verge is a Boulder, CO based firm specializing in eBusiness solutions with Enterprise JavaBeans.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

IoT & Smart Cities Stories
The platform combines the strengths of Singtel's extensive, intelligent network capabilities with Microsoft's cloud expertise to create a unique solution that sets new standards for IoT applications," said Mr Diomedes Kastanis, Head of IoT at Singtel. "Our solution provides speed, transparency and flexibility, paving the way for a more pervasive use of IoT to accelerate enterprises' digitalisation efforts. AI-powered intelligent connectivity over Microsoft Azure will be the fastest connected pat...
There are many examples of disruption in consumer space – Uber disrupting the cab industry, Airbnb disrupting the hospitality industry and so on; but have you wondered who is disrupting support and operations? AISERA helps make businesses and customers successful by offering consumer-like user experience for support and operations. We have built the world’s first AI-driven IT / HR / Cloud / Customer Support and Operations solution.
Codete accelerates their clients growth through technological expertise and experience. Codite team works with organizations to meet the challenges that digitalization presents. Their clients include digital start-ups as well as established enterprises in the IT industry. To stay competitive in a highly innovative IT industry, strong R&D departments and bold spin-off initiatives is a must. Codete Data Science and Software Architects teams help corporate clients to stay up to date with the mod...
At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...
Druva is the global leader in Cloud Data Protection and Management, delivering the industry's first data management-as-a-service solution that aggregates data from endpoints, servers and cloud applications and leverages the public cloud to offer a single pane of glass to enable data protection, governance and intelligence-dramatically increasing the availability and visibility of business critical information, while reducing the risk, cost and complexity of managing and protecting it. Druva's...
BMC has unmatched experience in IT management, supporting 92 of the Forbes Global 100, and earning recognition as an ITSM Gartner Magic Quadrant Leader for five years running. Our solutions offer speed, agility, and efficiency to tackle business challenges in the areas of service management, automation, operations, and the mainframe.
The Jevons Paradox suggests that when technological advances increase efficiency of a resource, it results in an overall increase in consumption. Writing on the increased use of coal as a result of technological improvements, 19th-century economist William Stanley Jevons found that these improvements led to the development of new ways to utilize coal. In his session at 19th Cloud Expo, Mark Thiele, Chief Strategy Officer for Apcera, compared the Jevons Paradox to modern-day enterprise IT, examin...
With 10 simultaneous tracks, keynotes, general sessions and targeted breakout classes, @CloudEXPO and DXWorldEXPO are two of the most important technology events of the year. Since its launch over eight years ago, @CloudEXPO and DXWorldEXPO have presented a rock star faculty as well as showcased hundreds of sponsors and exhibitors! In this blog post, we provide 7 tips on how, as part of our world-class faculty, you can deliver one of the most popular sessions at our events. But before reading...
DSR is a supplier of project management, consultancy services and IT solutions that increase effectiveness of a company's operations in the production sector. The company combines in-depth knowledge of international companies with expert knowledge utilising IT tools that support manufacturing and distribution processes. DSR ensures optimization and integration of internal processes which is necessary for companies to grow rapidly. The rapid growth is possible thanks, to specialized services an...
At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...