Java IoT Authors: Yeshim Deniz, Elizabeth White, Pat Romanski, Liz McMillan, Zakia Bouachraoui

Related Topics: Java IoT

Java IoT: Article

Splitting Tiers

Splitting Tiers

The story about how the n-tier architectures evolved from the single-tier mainframe model has probably been told umpteen times by now (in fact, I retold it myself in last month's e-Java column). Nowadays the trend is to distribute functionality. Modularize everything. Components provide the means to successfully replicate your product in a gazillion scenarios. Client/server is old news. Think distributed architectures. Personalized Webtops. That's the name of the game today.

It's easy to get caught up in the hype and lose touch with reality. The Internet fosters a new type of dynamics that encourages and embraces change faster than the stability of technology. It's an ever-increasing challenge for developers and architects to make decisions regarding when to adopt a new technology and how long to retain the old one. The complexity of these decisions is compounded in that computing technologies usually span multiple tiers of an n-tier application. Development managers and project managers face their own problems when dealing with distributed architectures. One of them is how to structure the development team such that the skillsets of the team members map across the various technologies used to implement the business solution. Who is the architect and how does he or she keep a handle on both ends of the spectrum - from the back office to the front-end browser? What kind of middleware expertise is needed? What kind of GUI needs to be built and how much are the tools going to cost? How does the team responsible for the middleware interact with the front-end Web developers?

One way to alleviate the risk in making such decisions is to clearly define what the tiers of the architecture are going to be and how the functionality of your application maps to those tiers. Everybody talks about n-tier architectures and distributed architectures. But the bottom line is - How do you serve up data to your clients? This month in e-Java we'll start from where we left off last month.

We'll revisit the four basic tiers of a distributed e-commerce application. Our focus will be more on the front end and middle tiers, and on some alternative Java and Web technologies available in the market to implement functional modules in business applications.

The Four Tiers
A typical distributed architecture that nurtures e-commerce applications consists of four-tiers:

  • Client user interface tier
  • Presentation tier
  • Business logic tier
  • Data access tier
Table 1 describes the purpose of each tier in an e-commerce application. In today's Web applications all of us strive to make the client as thin as possible. One of the main reasons for this is that end-user devices today range from desktop PCs to handheld PCs, cell phones and pagers. Thus, in the optimum distribution of tiers, the client UI tier will have minimum functionality; its only purpose will be to render the data on the screen using the display device's native graphic utilities. The thinnest "universal" client in today's distributed systems is the browser.

After All, It's All HTML
When it comes to the browser-based UI, all the data that the browser renders is interpreted from HTML. This means that the next tier down in the distributed system serves up HTML to the client. Traditional HTML serves static data only. To provide the high degree of interactivity typical of e-commerce transactions, HTML allows Web developers to embed tags that direct the browser to get fresh data from the server.

Why do we have to go to the server to get data? Because the thin client doesn't do anything else but display data; it doesn't produce data. That's the job of the presentation tier.

Java applets provide a way to dynamically generate HTML content. However, applets are downloaded to the client and executed there, thus making the client thicker. Applets enable highly interactive behavior for the client and are good for calculations that can be conducted on the client side. But more complex computations that involve frequent data access (and require security) on the server side need to be executed in the next tier. This is the presentation tier and its responsibility in our context is serving up HTML to the browser-based client.

Splitting the Middle Tier
Thus dynamic content is generated by the tier next to the client UI. This tier, called the middle tier in traditional three-tier systems, could basically access the data from the back-office system, apply business logic to it and serve up HTML to the client. So why split this into a presentation and a business logic tier? Let me answer that question with another question. How do you get data from your data source that resides in the back office? The data could be obtained from sources of various types - database server, file servers, LDAP servers or some legacy system's proprietary interface. The result is that the means of getting the data will differ. Depending on the back-office interface, the middle tier's connection to the back office could be via DCOM, CORBA, RMI, raw HTTP or a variety of other protocols. The scope of a transaction could be very different, depending on the business logic defined in the middle tier. If it's the same logical layer that deals with presentation logic as well as business logic, it becomes very complex. Also, since it's tightly coupled with the back office, it becomes less flexible and nonportable. This leads to scalability and performance issues.

The popular approach to solve these problems is to allow multiple application objects in a business logic layer. These application objects are responsible for getting the data from the server and making it available to the presentation layer. The presentation layer generates the dynamic HTML and makes it available to the client browser.

Generating Dynamic Content
The presentation layer has several alternatives for generating the dynamic content and serving it back to the client. The most popular approaches are via server-side scripting, Java servlets and Java Server Pages (JSPs), and Active Server Pages (ASPs). ASPs, Microsoft's technology for accessing COM objects, are beyond the scope of this article. JSPs are Java's counterpart to ASPs (hence the name JSP) and are Sun's technology for accessing Java objects on the server. All services on the servlets are Java's gateway to all services on the server side. Servlets are always associated with a Web server. They're created as server threads as a result of a client's HTTP request and they serve up HTML content as a response. A JSP allows developers to embed Java code in HTML pages. These hybrid pages have a .jsp extension and can contain a combination of HTML, Java code and JavaBean components. When the client makes an HTTP request, the servlet engine on the server compiles the JSPs into corresponding servlets.

Another way to add dynamism to HTML is via server-side scripting using JavaScript or JScript. Scripting code is embedded in the page. The difference is that, unlike JSPs, scripting code isn't compiled, it's interpreted. Although this is slower, it's faster to develop, prototype and test. Another popular middleware technique for generating dynamic HTML is to use extensions to HTML tags, which allow the page to access dynamic content. This technique is offered by Web application programming languages like Allaire's CFML.

These presentation technologies are still needed to talk to the business logic tier in order to actually obtain the data that needs to be presented. That is where server-side technologies like EJBs and COM come into the picture. The business logic and data source accessibility is abstracted by these technologies.

E-Commerce Functional modules
The technologies selected for your application should be based on the behavior that's expected from the functional module. For example, you can create a shopping cart component using CGI, JavaScript, servlets, JSPs, CFML or other types of dynamic-content generation technologies. However, when settling on a technology, you should ask yourself what the interface to the business logic tier is. Are your business objects COM objects, EJB objects or just database adapters? Can you access the COM objects via CORBA? Is there even a need to talk to the business logic tier for all transactions? For example, if the next step in your workflow is a credit card payment, the information doesn't need to go beyond the presentation layer, provided that the presentation layer has hooks into a credit card payment system like CyberCash.

One of the unique features offered by technologies like CFML is that it allows you to embed SQL inside your HTML. This means you can access the database directly from your HTML page as opposed to going to a business logic layer. This allows you to segregate your database into a front-end database, which could contain, for example, user profiles, account information and maybe local catalog information. On the other hand, if you need to access services offered by the back office such as information pulled out in real time from a reservation engine, you probably need to call Java or COM objects on the server side. In addition, if your catalog information is dependent on business rules that tie into the back office, then you'd probably like to go through a business logic tier. In that case JSPs may be a better alternative to build your shopping cart.

Trading Places
The notion of splitting the middle tier is important for building robust and flexible business applications. You may also want to divide the responsibility of load balancing and fault tolerance between the two middle-tier layers (presentation and business logic). For example, both ColdFusion (presentation) and WebLogic (business logic) offer clustering capabilities. Some transactions, such as credit card payments or catalog queries, may not need to go back to the business logic tier. Decoupling these two layers gives a large boost to scalability.

In the end, what the end user sees is your workflow that abstracts him or her from all these complexities. However, as someone who provides e-business solutions, I believe it's our job to create these abstractions to offer a more satisfying experience for the users of our systems.

Starting this month, I'd like to add a monthly book review to the e-Java column, an idea I am shamelessly stealing from Alan Williamson of Straight Talking fame. Having received mail from several readers who have asked about good sources of information on several topics, I figured this is a good way to share my opinion on recently released books with all you fine folks.

In the mad rush for deliverables and the race to overcome the time-to-market dilemma, I find myself more often than not desperately trying to catch up on technology. In Java, that roughly translates to new APIs. Since I returned to Dallas pumped up from JavaOne in June, I've been trying to find time to catch up on J2EE. O'Reilly & Associates' Nutshell Handbook series seems to be created for such situations. Java Enterprise in a Nutshell: A Desktop Quick Reference is a great book if you want to get a quick ramp-up on the J2EE APIs.

It starts off where Java in a Nutshell ended. This is an excellent reference, but it's not for everyone. If you're looking for a comprehensive Java reference that covers Java in all its glory, this isn't the book for you - try Core Java published by Prentice Hall. If you're looking for a book on Java 1.1 APIs, don't start with this one - start with its predecessor.

If you know core Java, however, and are interested in a quick introduction to the APIs provided by the Java platform for developing enterprise applications, make sure you get a copy of Java Enterprise in a Nutshell. In typical "nutshell" style, Part I starts with a quick introduction to the Java enterprise APIs, and also gives a concise explanation of what enterprise computing means and how it relates to Java. The diagram on page 12 and the corresponding discussion in chapter 1 are instrumental in bringing readers up to speed with the current role of Java APIs in an e-commerce application. Part II covers the J2EE APIs - JDBC, RMI, Java IDL, Java servlets, JNDI and EJBs. There's just enough code to get your feet wet. If you want to look up an API, read the corresponding chapter, play around with the examples and then go write your application. For more detail and complex examples you'll have to get a book that focuses on that particular API. Finally, Part III of the book is a comprehensive quick reference for the enterprise APIs.

All in all, this is a good book to add to your library. And it's light enough to haul along if you have to travel.

More Stories By Ajit Sagar

Ajit Sagar is Associate VP, Digital Transformation Practice at Infosys Limited. A seasoned IT executive with 20+ years experience across various facts of the industry including consulting, business development, architecture and design he is architecture consulting and delivery lead for Infosys's Digital Transformation practice. He was also the Founding Editor of XML Journal and Chief Editor of Java Developer's Journal.

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
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...
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...
Where many organizations get into trouble, however, is that they try to have a broad and deep knowledge in each of these areas. This is a huge blow to an organization's productivity. By automating or outsourcing some of these pieces, such as databases, infrastructure, and networks, your team can instead focus on development, testing, and deployment. Further, organizations that focus their attention on these areas can eventually move to a test-driven development structure that condenses several l...
The graph represents a network of 1,329 Twitter users whose recent tweets contained "#DevOps", or who were replied to or mentioned in those tweets, taken from a data set limited to a maximum of 18,000 tweets. The network was obtained from Twitter on Thursday, 10 January 2019 at 23:50 UTC. The tweets in the network were tweeted over the 7-hour, 6-minute period from Thursday, 10 January 2019 at 16:29 UTC to Thursday, 10 January 2019 at 23:36 UTC. Additional tweets that were mentioned in this...
Over the course of two days, in addition to insightful conversations and presentations delving into the industry's current pressing challenges, there was considerable buzz about digital transformation and how it is enabling global enterprises to accelerate business growth. Blockchain has been a term that people hear but don't quite understand. The most common myths about blockchain include the assumption that it is private, or that there is only one blockchain, and the idea that blockchain is...
Never mind that we might not know what the future holds for cryptocurrencies and how much values will fluctuate or even how the process of mining a coin could cost as much as the value of the coin itself - cryptocurrency mining is a hot industry and shows no signs of slowing down. However, energy consumption to mine cryptocurrency is one of the biggest issues facing this industry. Burning huge amounts of electricity isn't incidental to cryptocurrency, it's basically embedded in the core of "mini...
In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
The term "digital transformation" (DX) is being used by everyone for just about any company initiative that involves technology, the web, ecommerce, software, or even customer experience. While the term has certainly turned into a buzzword with a lot of hype, the transition to a more connected, digital world is real and comes with real challenges. In his opening keynote, Four Essentials To Become DX Hero Status Now, Jonathan Hoppe, Co-Founder and CTO of Total Uptime Technologies, shared that ...
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...
Every organization is facing their own Digital Transformation as they attempt to stay ahead of the competition, or worse, just keep up. Each new opportunity, whether embracing machine learning, IoT, or a cloud migration, seems to bring new development, deployment, and management models. The results are more diverse and federated computing models than any time in our history.