O'Reilly logo

Building Java Enterprise Applications by Brett McLaughlin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 1. Introduction

Java has become a confusing world. Five years ago, there were few decisions to make once you started programming in Java—you used AWT for graphical user interfaces, sockets for network programming, and hacked together everything else you needed. Since then, though, the APIs available for the Java language have grown, and grown. . . and grown. Now you can dabble in Swing, servlets, Enterprise JavaBeans (EJB), JavaMail, and more. Additionally, there are now packages of APIs, like the Java 2 Micro Edition (J2ME) and Java 2 Enterprise Edition (J2EE). While these packages seem to be nicely wrapped bundles of useful APIs, they don’t help the average developer figure out how to piece together the APIs contained in these packages. Though it’s simple to find documentation on the individual APIs, getting the “big picture” is difficult, at best. One of the most interesting, but difficult, aspects of Java today is building Java enterprise applications using the J2EE package.

All of this has led the folks at O’Reilly to be interested in a book specifically focused on building enterprise applications with these APIs. Instead of small, piecemeal examples, we’ve found that readers want large applications built from the ground up, and explanations of design decisions. Additionally, readers have been adamant about seeing more than just the Java part of the picture; they want to know how to set up a database, and get an LDAP store running, and integrate these. How does a UDDI registry fit into the equation? I’m going to address all of these issues in this series (yes, I said series!) of books, Building Java Enterprise Applications. You hold Volume I in your hands.

So, this chapter is a true introduction. Not only will it introduce you to what I’ll be covering in this book and the materials you’ll need to follow along, but it will also tell you how this series is going to be put together. You’ll see what’s coming in Volumes II and III, how the examples are structured, and what topics will be covered in this book as well as future ones.

I’m glad you’re willing to come along with me as we try something new. And, with that, let’s get down to the details of building enterprise applications.

Building Java Enterprise Applications

From the first page of the first chapter to the last page of the last index, this series is going to focus on building applications. That probably sounds redundant, since you picked up this book knowing the title, but let me explain what I mean. First, I’m not going to explain the basics of the technologies used in this book. If you don’t know what an entity bean is, or haven’t ever written a SQL statement, or want to learn about JSPs, this book isn’t for you. I’d recommend you pick up a copy of the O’Reilly book on the subject you want to learn about, and start there. Section 1.3.3 at the end of this chapter is a good reference for linking a subject to the right O’Reilly book.

Second, this book is aimed squarely at the enterprise developer, and especially at someone who has an existing or upcoming project that uses all or part of the J2EE platform. I’ll explain later what constitutes an enterprise application, but this book will be most helpful if you have some real business problems to solve and can apply the concepts in these chapters directly to them.

Third, I expect you to be comfortable with (and hopefully, desirous of) lots of code. I’m going to try to keep explanations to the bare minimum on basic concepts, and instead focus on tougher problems, real-world issues that aren’t covered in other books, and typical mistakes I see in day-to-day programming. If you’re not ready to wade through a lot of code (thousands of lines in this volume, for starters), you might want to set this down and pick it up again once you’ve had a little more experience (as if any real programmer would put something down because it’s over their head!).

Fourth, this book focuses on writing applications from the ground up, using only Java as the programming language. While many enterprise applications do have to deal with legacy code or non-Java system integration, that is a topic well unto itself. To keep things clear and concise, this book deals with systems that are entirely based on the Java programming language. While the third volume on web services will certainly touch on integration with other languages, this architecture volume does not.

And finally, I’m hoping that you’re willing to work through this volume, and even the rest of the series, chapter by chapter, example by example. I’ll be taking you through the building of a non-trivial application in this book, and continue on with that example over the next two volumes. Although all the code covered will be available online, I’ve presented things in a manner that assumes you’re going through the code with me. So even if you don’t usually do this sort of thing, you might want to try it for this book, as it will really help you out. Also, the next two volumes will assume that you’ve got the code from this book working, as we’ll be building on top of that infrastructure. To help you see how things will fit together, let’s now walk through the three volumes that will make up this series.

Tip

Lest any of you go to the bank on the description of the series presented here, I should warn you that as with all plans, things may change. Additionally, the folks at O’Reilly have had lots of discussion about whether to first put out a volume on traditional web applications (servlets, JSP, HTML) or on web services (SOAP, UDDI, WSDL). So, if you’ve got an opinion, let us know! There are details on getting in touch with us in the the preface of this book, and I look forward to hearing your thoughts.

Volume I: Architecture

This first volume focuses on application architecture and serves as the foundation for the next two volumes. I’ll dive a little further into the specifics of what this book covers in the next section.

Any enterprise application has two baseline components: design and data stores. The first of these components, design, turns out to be more about concepts and theory than about actual programming. In fact, most developers rush right through this step because they want to get to coding, and almost inevitably end up paying a price for that haste later on. In light of that, this book pays a lot of attention to design decisions involved in enterprise applications. Additionally, it lays out the process flow for database interaction, and sets up connectors for allowing our later work with web applications and web services to interact with the infrastructure set up in this book.

Additionally, this volume will spend a lot of time detailing how to develop data stores for use in these applications. Obviously, this involves databases, from designing tables and columns to dealing with database sequences and triggers. Since each database has its own unique features, appendixes are included to offer advice on vendor-specific variations in SQL and on how to optimize your code for specific databases. Additionally, I’ll spend a good bit of time delving into directory services and explaining how authentication data should be handled differently from application data. This will set the stage for the EJBs discussed in this book, which are also used heavily in the second and third volumes.

Volume II: Web Applications

The second volume in the series will continue where Volume I leaves off, adding a web application front-end to the architecture designed in the first book. In this volume, web application means using J2EE technologies (servlets, JDBC, JSPs) and HTML to construct an HTTP-accessible application front-end. In addition to explaining how these APIs fit together, this volume will also connect these front-end components to the back-ends created in Volume I. RMI, EJBs, JDBC, and more will be explained in light of the web application.

I’ll also explain how various XML-based solutions like XSL and XML transformations can provide alternatives to HTML user interfaces. Although not completely integrated into the J2EE platform, XML and related technologies are becoming a vital part of any large-scale application, especially one that serves both static and dynamic content. I’ll also look at XML data binding, RSS, and other means of communicating content between application front-ends.

Finally, some of the satellite components of J2EE, such as JavaMail, will be explained and discussed in relation to a functioning web application. While not critical for typical applications, these APIs can be immensely helpful in implementing an additional layer of communication between your applications and the end user. By the end of this volume, you’ll not only have a complete understanding of web applications, but you’ll have built a front-to-back practical solution (using the example code of Volumes I and II).

Volume III: Web Services

The third volume in this series will focus specifically on web services. It takes the business components discussed in Volume I (EJBs and other Java classes) and explains how they can be converted into web services using technologies such as SOAP and WSDL. Issues related to security, communication, and service registration will be explored. This is presented as a contrast to the web application interface discussed in Volume II.

This volume will also discuss the considerations involved with transmitting data across a network. Custom data types, large amounts of information, and object serialization are all important considerations, and will be given detailed coverage. You’ll also learn how UDDI registries and WSDL are important not only in allowing component access, but also in restricting that access to only those methods you want to expose. Finally, exposing EJBs will be covered in detail.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required