Previous Table of Contents Next


Introduction

Java is steadily becoming the language of choice for new enterprise-wide development projects. A number of factors have lead to this explosion in Java’s popularity as a programming language and in particular as a language for large scale development projects. If you are reading this book, we expect that you already have some familiarity with Java as a programming language, and won’t bore you with the laundry list of marketing buzz words that are often used to excite folks about Java. Instead, we have focused this book on the enterprise technologies that Sun is standardizing for the Java developers. These technologies, as standards, are motivating numerous companies to move their new projects onto the Java platform.

Our goal for Developing Java Enterprise Applications is to provide developers and evaluators alike an opportunity to learn about Java enterprise development at a technology level and from the perspective of a real world project. There are a number of emerging Java technologies and we have taken a snapshot of the available libraries, frameworks, and tools. Certainly, the list of available technologies will grow, but this book should serve as a solid foundation for your Java development.

Currently the main technologies being adopted, or about to be adopted, by enterprise developers include JDBC for database connectivity, the Java Naming and Directory Interface (JNDI) for accessing services, and RMI for Java remote method invocation and distributed objects. On top of this foundation are Servlets, JavaServer Pages, Enterprise Java Beans, Java Messaging Service, and Transaction Management. All of these combine into a feature-rich tool kit for developing Java applications.

What about CORBA?

You may have noticed that in all this discussion, we have made no mention of one of the more pervasive and potential influential technologies in enterprise development, CORBA. In researching and writing this book, we realized that their just wasn’t room to do CORBA, and the Java technologies for accessing it, justice. Seeing the number of books that just discuss Java and CORBA, we decided that our time, and your money were better served discussing the other technologies well and leaving CORBA for a separate manuscript. We both realize that it would be short-sighted to expect Java developers to ignore CORBA, and we do not intend that. Rather, we decided to leave it out for the opposite reason, and ensure that your research into CORBA is complete and productive.

How This Book Is Organized

You will find three types of chapters in this book. First, each technology is introduced, the underlying concepts are discussed, and comparable technologies are described. Second, the programming techniques and technical concepts required to use a technology are described using small examples. These chapters provide a framework for studying larger examples. Each technology that this book focuses on has a targeted example provided for it. This example solves a medium size problem and provides a larger context for learning what the technology is for and how it is used. Finally, the book is concluded with two large examples. These tie together numerous concepts from the book and are intended to provide a stepping stone to your real world development projects.

At least that is the general idea. If we look at a specific example, Servlets, we see Chapter 6: What Are Servlets? introduces the concept of a servlet as a Web server extension. Chapter 7: Programming Servlets discusses the details of creating a servlet, and provides a number of small examples. Chapter 8: A Servlet-Based Search Engine demonstrates how servlets can be used to create a Web site search engine. Finally, Chapter 25: A Four-Tier Online Store uses a number of servlets in the creation of a small on-line store. And that’s just for servlets. RMI, JavaServer Pages, Enterprise Java Beans, and Java Messaging Service all have the same, if not more, coverage. Also, JDBC and JNDI have chapters to introduce them, and describe the basic techniques required to use them. We decided that since these technologies show up in so many other places, it wasn’t necessary to provide a single large example for them. One note about JBDC; it is a fairly lengthy topic, and if you are planning extensive database access we suggest that you use a book that focuses on JDBC. Like CORBA we didn’t think that we could meet our main goals and do JDBC justice. But we thought that it was necessary to provide the basics here as a foundation for the other examples.

Based on this underlying design template the book is organized into the following chapters:

Chapter 1: An Introduction to Java Enterprise Development introduces the technologies in this book and describes some of the fundamental concepts that these technologies are built on.
Chapter 2: What Is JDBC? introduces the Java Database Connectivity framework (JDBC) and describes the goals and basic architecture for this important library.
Chapter 3: Basic JDBC Programming discusses the basic techniques used to access databases with JDBC. Because JDBC is a large library we have not tried to provide a complete discussion of it. Instead, we introduce the basic techniques used to access data. These techniques are used in numerous examples throughout the book.
Chapter 4: What Is JNDI? introduces what the Java Naming and Directory Interface is and the design goals behind it. The discussion includes information on naming and directory services in general as well as how JNDI accesses them.
Chapter 5: Using JNDI describes and provides techniques for developing Java programs that access naming and directory services. These techniques are used later in the book for accessing Enterprise JavaBeans and Java Messaging Service facilities.
Chapter 6: What Are Servlets? introduces servlets and compares them with other Web server programming tools.
Chapter 7: Programming Servlets describes the techniques used to write servlets and the libraries that support servlets. This chapter also provides a number of example servlets for retrieving data from the user, sending data to the user and communicating between applets and servlets.
Chapter 8: A Servlet-Based Search Engine is the first focused example in the book. This chapter describes a servlet based Web site search engine, including the code for indexing HTML pages.
Chapter 9: What is Server-side Scripting? introduces the concept of server-side scripting for Web pages and compares the different techniques to JavaServer pages.
Chapter 10: Creating JavaServer Pages demonstrates the techniques and syntax used to create JavaServer Pages. Examples are used to highlight each concept.
Chapter 11: A JavaServer Page Online Store discusses a larger JavaServer Page example that defines an online store. This store dynamically provides an interface for a categorized group of products. Advertisements are displayed on pages, and new products can be added without changing the code.
Chapter 12: Overview of Distributed Objects introduces the concept of distributed objects and describes how Java RMI fits in to the distributed object realm.
Chapter 13: Introduction to Java RMI describes the techniques and tools used to create distributed Java applications using RMI. Examples are used to demonstrate important points, like class loading, object passing and distributed garbage collection. A small discussion is included, with an example, on the RMI Object Activation Framework provided with Java 2.
Chapter 14: A Network File Locking Server describes a larger RMI example that demonstrates how a server can be used to implement file locking on a single machine or the network.
Chapter 15: What are Enterprise JavaBeans introduces the powerful new technology called Enterprise JavaBeans. In this first discussion of EJB the various roles involved in creating Enterprise JavaBeans are listed and EJB is motivated as a development technology.
Chapter 16: Programming Enterprise JavaBeans discusses the techniques and libraries that programmers use to create Enterprise JavaBeans. Examples are used to highlight important concepts like Entity beans versus Session beans. Enterprise JavaBeans defines an important standard for developing server side code.
Chapter 17: Deploying Enterprise JavaBeans lists the steps used to deploy an EJB application on an application, or some other server. This Chapter is provided as an introduction to the basic issues when deploying EJB applications.
Chapter 18: Enterprise JavaBean Business Rules Engine describes an example Enterprise JavaBean application that uses a configurable rules engine to process check requests. This example demonstrates both the EJB technology and how scripting can be used to create dynamic business rules.
Chapter 19: What is Messaging and the Java Messaging Service? introduces the concept of messaging and how the Java Messaging Service supports this programming paradigm. Messaging is an alternative method for defining network communication and has begun to gain popularity for large, complex enterprise projects, especially for integrated disparate systems. This chapter also defines the basic messaging styles, including point-to-point and publish-subscribe.
Chapter 20: Programming With the Java Messaging Service demonstrates the techniques used to create applications that use JMS to send point-to-point and publish-subscribe style messages. Examples are provided for major concepts, including applications that send and receive messages using both styles.
Chapter 21: A JMS-Based Alarm System defines and describes a larger JMS application. This application uses messages to create an alarm system. Users can define alarms and have them triggered automatically at the appropriate time. This Chapter also includes an interesting library for managing timed notifications.
Chapter 22: Transactions, JTA, and JTS introduces the concept of a transaction and discusses the Java libraries being defined to manage them.
Chapter 23: Using Transactions with Enterprise JavaBeans relates transactions to Enterprise JavaBeans and provides examples of how an enterprise bean can manage its transactional context.
Chapter 24: Architecture Review ties many of the concepts in this book together and introduces the two large examples that conclude the book.
Chapter 25: A Four-Tier Online Store discusses an online store implementation. This store uses JavaServer pages and servlets to define a Web page interface. Servlets are used to manage searching and advertisement placements. A servlet is also defined to manage a shopping cart for the user. This servlet works with an Enterprise JavaBean to access data in a database about inventory and credit. Another servlet is provided for creating inventory reports.
Chapter 26: MiniJMS discusses an implementation of the JMS libraries. This JMS provider uses RMI, JDBC and JNDI to implement network messaging.

As you can see, the basic flow for each technology is an introduction followed by details and an example. Finally, two large examples are used to tie the concepts together. We strove for educational clarity and usefulness in our examples, so please do not consider them the end all be all of programming. We have tried to show the tradeoffs we made, but there were tradeoffs. Please keep this in mind as you study the example code.

Who Should Read This Book

This book is designed for two types of readers. First, technical evaluators should be able to use the introductory chapters to learn about each technology at a high level. Then the example chapters can provide demonstrations for what the technology can do. Experienced Java programmers can use the programming chapters to learn the new libraries and classes before diving into the example code to see how these programs really work and get ideas for their own projects. Both types of readers should be able to leverage the rules and guidelines throughout the book in future projects.

This book covers a lot of topics. You may want to read it straight through or jump around. In either case, keep in mind the design template discussed above so that you can jump to a technology without jumping into the middle of it, unless you want to. If you are planning to read the code for the examples, you should already have experience writing Java programs, including basic threads programming. If you have also used the networking libraries, that will help with some of the distributed technologies, although it is not a requirement.

Necessary Tools and CD-ROM Content

One problem we encountered when writing this book is that enterprise programming needs a lot of deployment support. In particular, JDBC needs a database to access, JNDI needs special service providers, Servlets and JavaServer Pages need a Web server, EJBs need a host and JMS requires a service provider as well. For JMS we have written a sample provider that is discussed in Chapter 26: MiniJMS. For JDBC we have often discussed ODBC to meet the most commonly available database engines. But we have also provided a demonstration version of Cloudscape’s JDMS a pure Java database engine on the CD-ROM. For EJB examples we have included a demonstration version of the BEA WebLogic application server on the CD-ROM. This server also provides some JNDI services, as do the sample providers available from Sun. For servlets, we have included the Servlet Development Kit. Unfortunately, you will need to download a server, possibly from Sun, that supports JavaServer pages to test the examples.

That’s quite a list. Each chapter that introduces a new technology will provide specific details for the programs and tools you need to run the examples from that chapter.

All of the examples rely on the standard Java Development Kit, we chose 1.1.6 and 1.2. Many use the Swing user interface library as well. Java 2 is provided on the CD-ROM, while both the 1.1 JDK and Swing can be downloaded from Sun’s Web site.

Although we did our testing on Windows NT, Windows95, and Windows98 all of the examples are pure Java and should be easily run on other platforms. Please refer to the Web site for this book at http://www.crl.com./~sasbury/ejava/ for the latest information on these examples. You can also use that site to let us know of any problems you have with a particular version or operating system so that we can let others know about those issues.

Note on Versions

Java is a growing, changing and expanding technology. You will always hear about the next version just when you learn the newest one. As authors this can be especially challenging for us. We have tried to provide the best available information in this book. However, we know of some rumors and releases already and for completeness have listed them here.

At the time we are writing, Enterprise JavaBeans was at version 1.0. Sun has already announced that there will be a “maintenance” release, probably called 1.1, that may appear before this book is published. This release is designed to fix bugs and resolve issues with the JDK security model. Sun is also working with its partners on EJB 2.0. Little information is available on this release at the time of this writing, but indications are that it will build on the 1.0 release, so what you learn here will provide a firm foundation for future versions. Sun has also indicated that they will probably provide a “reference implementation” for an EJB host. This will allow you to test your EJB projects in a product independent environment.

The Java transaction APIs were not finalized at the time of this writing and may change somewhat in early 1999. Please use the latest documentation on your EJB host and Sun’s Web site for information on transaction management. Keep in mind that changes to JTA may effect the EJB specification as well.

The Servlet specification is being refined and updated. Like EJB, the content of this book should provide a great foundation for your work with future versions of servlet programming. JavaServer pages are also being updated and the new specification is discussed in some detail in chapter 10.

Things will always be changing, but for enterprise projects you want a stable development platform. We strongly suggest that for at least the first half of 1999 that you stick to JDK 1.1.7 and possibly 1.2 for deployment. Also stay with the earlier versions of the enterprise APIs until the new versions are fully supported by your server vendors. This means EJB 1.0, JDBC 1.0 and the other versions discussed here. Although specifications are being updated it will often take time for the service providers to update their code. A great example of this is JDBC where 2.0 is nearly out but the drivers are not yet supporting it. As a result we have discussed 2.0 features but have not included examples of JDBC 2.0 here.

Summary

Our goal in writing this book was to provide a solid, example rich, introduction to the Enterprise Java Technologies. We can’t hope to discuss every issue in enterprise development, despite how hard we tried. We can hope that you will use this book to start your journey into Java enterprise development. Please let us know how you do and what you would like to see in future books so that we can continue to provide a solid programming introduction to new technology.


Previous Table of Contents Next