Thinking in Enterprise Java.pdf

(642 KB) Pobierz
Thinking in Enterprise Java
Thinking in Enterprise Java
file:///C:/DOCUME~1/Usuario/LOCALS~1/Temp/Rar$EX05.750/TI...
by Bruce Eckel et. Al.
Revision 1.1, 5-06-2003
Please note this document is under development and incomplete. Updates to this
document can be found at http://www.Mindview.net
Best viewed with Mozilla! (free at www.Mozilla.org ) (Even though this document
was created with MS Word, IE6 garbles lines with footnote markers on them. Mozilla
seems to do a much better job).
___________________________________________
Note: This document requires the installation of the fonts Georgia, Verdana and Andale Mono (code
font) for proper viewing. These can be found at:
http://sourceforge.net/project/showfiles.php?group_id=34153&release_id=105355
Modifications in Revision 1.1:
· Removed superscripts to improve viewing with IE
Modifications in Revision 1.0:
· Raw assembly of initial document. Please donÓt expect too much at this point, weÓre just getting
started.
· Some material is carried forward from Thinking in Java 2nd edition, some material is new.
· No feedback mechanism in place at this time
1 of 168
22/05/2007 09:27
Thinking in Enterprise Java
Thinking in Enterprise Java
file:///C:/DOCUME~1/Usuario/LOCALS~1/Temp/Rar$EX05.750/TI...
Contents
Introduction to Enterprise Programming
Prerequisites
Summary
Network programming with Sockets & Channels
Identifying a machine
Servers and clients
Testing programs without a network
Port: a unique place within the machine
Sockets
A simple server and client
Serving multiple clients
Datagrams
Using URLs from within an applet
Reading a file from the server
Selector Based Multiplexing in JDK1.4
More to networking
Exercises
Remote Method Invocation (RMI)
Remote interfaces
Implementing the remote interface
Setting up the registry
Creating stubs and skeletons
Using the remote object
Summary
Exercises
Connecting to Databases
Getting the example to work
Step 1: Find the JDBC Driver
Step 2: Configure the database
Step 3: Test the configuration
Step 4: Generate your SQL query
Step 5: Modify and paste in your query
A GUI version of the lookup program
Why the JDBC API seems so complex
A more sophisticated example
Summary
Exercises
2 of 168
22/05/2007 09:27
63460382.001.png
Thinking in Enterprise Java
file:///C:/DOCUME~1/Usuario/LOCALS~1/Temp/Rar$EX05.750/TI...
Servlets The basic servlet
Servlets and multithreading
Handling sessions with servlets
The Cookie class
The Session class
Running the servlet examples
Summary
Exercises
JavaServer Pages
Implicit objects
JSP directives
JSP scripting elements
Extracting fields and values
JSP page attributes and scope
Manipulating sessions in JSP
Creating and modifying cookies
JSP summary
Exercises
Custom Tags
What do custom tags give us?
Using Tags and JavaBeans
Tags that manipulate their body content
Tags that iterate
Tags within Tags
The Tag Classes
Using TagExtraInfo classes
Tag Library Descriptors Revisited
Deploying Tag Libraries
Using Third Party Tag Libraries
Enterprise JavaBeans
Enterprise JavaBean Flavors
EJB Roles
The Basic APIs
JNDI
EJB
EJB Container internals
Software
The example application
Your first Enterprise JavaBean
Home Interface
Component Interface
Primary Key
Implementation Class
Deployment Descriptor
Packaging
Deployment
Building it all
An EJB client application
Simplifying EJB Development
Implementing a session bean
EJB Local Interfaces
3 of 168
22/05/2007 09:27
63460382.002.png
Thinking in Enterprise Java
file:///C:/DOCUME~1/Usuario/LOCALS~1/Temp/Rar$EX05.750/TI...
Bulk accessors and value objects
Finder Methods and EJB-QL
Entity Relationships
Summary
Resources
XML
What is XML?
XML Elements
XML Attributes
Character Sets
XML Technologies
JAXP Î Processing XML
XML Namespaces
Well-Formed and Valid XML
Validating Parsers: SAX and DOM
SAX
DOM
Plus and Minus of SAX and DOM
XML Serialization
Xerces Serialization
DOM Level 3 Serialization
XPath
XML Transformations
XML to HTML: Displaying a menu
The Root Node
XLink and XPointer
Summary
4 of 168
22/05/2007 09:27
 
Thinking in Enterprise Java
file:///C:/DOCUME~1/Usuario/LOCALS~1/Temp/Rar$EX05.750/TI...
Introduction to
Enterprise Programming
Historically, programming across multiple machines has been error-prone,
difficult, and complex.
The programmer had to know many details about the network and sometimes even the hardware. You
usually needed to understand the various ÐlayersÑ of the networking protocol, and there were a lot of
different functions in each different networking library concerned with connecting, packing, and
unpacking blocks of information; shipping those blocks back and forth; and handshaking. It was a
daunting task.
However, the basic idea of distributed computing is not so difficult, and is abstracted very nicely in the
Java libraries. You want to:
· Get some information from that machine over there and move it to this machine here, or vice
versa. This is accomplished with basic network programming.
· Connect to a database, which may live across a network. This is accomplished with Java
DataBase Connectivity (JDBC), which is an abstraction away from the messy, platform-specific
details of SQL (the structured query language used for most database transactions).
· Provide services via a Web server. This is accomplished with JavaÓs servlets and JavaServer
Pages (JSPs).
· Execute methods on Java objects that live on remote machines transparently, as if those objects
were resident on local machines. This is accomplished with JavaÓs Remote Method Invocation
(RMI).
· Use code written in other languages, running on other architectures. This is accomplished using
the Extensible Markup Language (XML), which is directly supported by Java.
· Isolate business logic from connectivity issues, especially connections with databases including
transaction management and security. This is accomplished using Enterprise JavaBeans (EJBs).
EJBs are not actually a distributed architecture, but the resulting applications are usually used in
a networked client-server system.
· Easily, dynamically, add and remove devices from a network representing a local system. This is
accomplished with JavaÓs Jini.
Please note that each subject is voluminous and by itself the subject of entire books, so this book is only
meant to familiarize you with the topics, not make you an expert (however, you can go a long way with
the information presented here).
Prerequisites
This book assumes you have read (and understood most of) Thinking in Java, 3rd Edition
(Prentice-Hall, 2003, available for download at www.MindView.net).
Summary
5 of 168
22/05/2007 09:27
Zgłoś jeśli naruszono regulamin