Java IoT Authors: Pat Romanski, Zakia Bouachraoui, William Schmarzo, Elizabeth White, Yeshim Deniz

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
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...
Tapping into blockchain revolution early enough translates into a substantial business competitiveness advantage. Codete comprehensively develops custom, blockchain-based business solutions, founded on the most advanced cryptographic innovations, and striking a balance point between complexity of the technologies used in quickly-changing stack building, business impact, and cost-effectiveness. Codete researches and provides business consultancy in the field of single most thrilling innovative te...
Darktrace is the world's leading AI company for cyber security. Created by mathematicians from the University of Cambridge, Darktrace's Enterprise Immune System is the first non-consumer application of machine learning to work at scale, across all network types, from physical, virtualized, and cloud, through to IoT and industrial control systems. Installed as a self-configuring cyber defense platform, Darktrace continuously learns what is ‘normal' for all devices and users, updating its understa...
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...
CloudEXPO has been the M&A capital for Cloud companies for more than a decade with memorable acquisition news stories which came out of CloudEXPO expo floor. DevOpsSUMMIT New York faculty member Greg Bledsoe shared his views on IBM's Red Hat acquisition live from NASDAQ floor. Acquisition news was announced during CloudEXPO New York which took place November 12-13, 2019 in New York City.
OpsRamp is an enterprise IT operation platform provided by US-based OpsRamp, Inc. It provides SaaS services through support for increasingly complex cloud and hybrid computing environments from system operation to service management. The OpsRamp platform is a SaaS-based, multi-tenant solution that enables enterprise IT organizations and cloud service providers like JBS the flexibility and control they need to manage and monitor today's hybrid, multi-cloud infrastructure, applications, and wor...
The Master of Science in Artificial Intelligence (MSAI) provides a comprehensive framework of theory and practice in the emerging field of AI. The program delivers the foundational knowledge needed to explore both key contextual areas and complex technical applications of AI systems. Curriculum incorporates elements of data science, robotics, and machine learning-enabling you to pursue a holistic and interdisciplinary course of study while preparing for a position in AI research, operations, ...
Atmosera delivers modern cloud services that maximize the advantages of cloud-based infrastructures. Offering private, hybrid, and public cloud solutions, Atmosera works closely with customers to engineer, deploy, and operate cloud architectures with advanced services that deliver strategic business outcomes. Atmosera's expertise simplifies the process of cloud transformation and our 20+ years of experience managing complex IT environments provides our customers with the confidence and trust tha...
With the introduction of IoT and Smart Living in every aspect of our lives, one question has become relevant: What are the security implications? To answer this, first we have to look and explore the security models of the technologies that IoT is founded upon. In his session at @ThingsExpo, Nevi Kaja, a Research Engineer at Ford Motor Company, discussed some of the security challenges of the IoT infrastructure and related how these aspects impact Smart Living. The material was delivered interac...
Intel is an American multinational corporation and technology company headquartered in Santa Clara, California, in the Silicon Valley. It is the world's second largest and second highest valued semiconductor chip maker based on revenue after being overtaken by Samsung, and is the inventor of the x86 series of microprocessors, the processors found in most personal computers (PCs). Intel supplies processors for computer system manufacturers such as Apple, Lenovo, HP, and Dell. Intel also manufactu...