106. Advanced Java
Programming
Rev. 1.4
This course is now available directly from our partner, Capstone Courseware.
This course provides advanced training in developing software using
the Java 2 Platform, Standard Edition, or J2SE.
It is intended for students with solid experience in structured and
object-oriented Java programming, including use of the Collections API and
exception handling. The course software
also includes an optional overlay of workspace and project files to support use
of the Eclipse IDE in the classroom.
(This requires that the instructor be experienced in use of Eclipse and
able to walk students through basic tasks in the IDE.)
The course is organized into four modules. The first covers several general-purpose
topics such as writing multi-threaded applications, the Reflection API, and
network programming using sockets. Then
the course takes up the challenge of building multi-tier applications using the
standard Java platform. Multi-tier
development most frequently uses the Java 2 Platform, Enterprise Edition, or
J2EE, and we have a wide range of courses in that area. However it is quite possible to build
lightweight multi-tier applications using only J2SE, and for some purposes the
J2EE is moure trouble than it’s worth.
So the course looks at each of the traditional tiers and the J2SE
APIs most suited to developing them. The
second module of the course covers the Java Foundation Classes, or JFC, for
building graphical user interfaces (GUIs) for the presentation tier. The third module introduces Java Remote
Method Invocation, or RMI, as a way of distributing Java objects over multiple
processes, which may be spread over a network of machines; this provides a
means of developing a separate business tier.
Finally, the fourth module teaches the Java Database Connectivity, or
JDBC, API, for the persistence tier. Students
will complete the course with a good working knowledge of each of these
technologies, prepared to build distributed Java applications and to pursue
JFC, RMI, or JDBC in greater depth.
LEARNING OBJECTIVES
·
Write multi-threaded Java applications.
·
Use the Reflection API for highly generic tasks,
discovery, or code-generation.
·
Communicate between processes using network
sockets.
·
Understand the basics of the JFC architecture.
·
Build simple GUI applications using JFC.
·
Build more complex GUIs using various JFC
controls.
·
Use the many hooks into the JFC architecture to
easily customize rendering and editing within JFC controls.
·
Understand the significance of the MVC
decomposition in using JFC controls.
·
Build GUI classes that make effective use of events
as fired from model, view and controller elements of the GUI itself.
·
Understand the role of Java RMI in distributed
Java software development.
·
Understand the relationship between RMI and
various J2EE technologies such as JNDI, EJB, and CORBA.
·
Understand the RMI framework and architecture,
especially the role of generated stubs and skeletons.
·
Implement simple RMI clients and servers.
·
Connect to a database using JDBC and perform a
simple query.
·
Update relational data using JDBC to execute
updates, inserts and deletes.
·
Use prepared statements to produce reusable
database queries and optimize execution time.
·
Use callable statements to access database
procedures.
·
Use scrollable and updatable results sets for
more robust solutions.
·
Use commit, rollback, and savepoint to build
transactional systems.
·
Use batch processing for efficient handling of
large datasets.
Duration: 5 days.
Prerequisites: Students must be experienced Java
programmers, able to build, test, and debug complex applications using structured
and object-oriented code designs, and familiar with the Collections API and
Java exception-handling. Either of
Object Innovations’ Courses 103 or 104
would be excellent preparation.
Module 1. Advanced Java APIs
1. Threads
Java Thread Model
Threads and ThreadGroups
Creating and Running Threads
Manipulating Thread
State
Creating Thread Classes
Thread Synchronization
Java 1.5: Concurrency Library
wait and notify
join and sleep
2. Reflection
Uses for Meta-Data
The Reflection API
The Class Class
The java.lang.reflect Package
Reading Type Information
Navigating Inheritance Trees
Dynamic Instantiation
Dynamic Invocation
Java 1.5: Annotations and Aspect-Oriented Programming
3. Serialization
The Challenge of Object Serialization
Serialization API
Serializable Interface
ObjectInputStream and ObjectOutputStream
The Serialization Engine
Transient Fields
readObject and writeObject
Externalizable Interface
4. Sockets
The OSI Reference Model
Network Protocols
The Socket Class
The ServerSocket Class
Connecting Through URL Objects
HTTP and Other TCP Servers
Datagram Clients and Servers
Non-Blocking Sockets
Module 2. The Java
Foundation Classes
1.
Introduction to JFC
Abstract Windowing Toolkit Basics
Simple Layout Management
Simple Event Handling
Lightweight Controls
JFC Feature Set
JFC Architecture and Relationship to AWT
2.
JFC Application Design
Role of a JFrame
Building a Frame-Based JFC Application
Panes
Using Dialogs
3.
JFC Components
JFC Component Class Hierarchy
JComponent Features
Simple Control Types
Text Components
Menus
Managing Look and Feel
4.
Architectural Patterns
Observer Pattern
Model-View-Controller Decomposition
Strategy Pattern
JList
Factory Pattern
JComboBox
Module 3. Java Remote Method
Invocation
5.
RMI Architecture
Motivation for RMI
RMI and EJB
RMI and CORBA
Overview of RMI Architecture
Stubs and Skeletons
Remote Reference Layer
RMI Transport
Lifetime of a Remote Method Invocation
RMI Registry
Naming and URL Resolution
RMI Up and Running
6.
RMI Implementation
Interface Design
The Remote Interface
Implementation Classes
The RemoteObject and RemoteServer Classes
The UnicastRemoteObject Class
Server Implementation
Using the Registry
Client Implementation
Code Deployment
7.
Practical RMI
Stub Source Code
RMI Marshaling
Skeleton Source Code
Diagnostic Code Using RemoteServer
Passing Objects
The Factory Pattern
Serialization vs. Remote Reference
Designing for Latency
The Value Object Pattern
Exception Handling
Module 4. Java Database
Connectivity
1.
Database and SQL Fundamentals
Relational Databases and SQL
Database, Schema, Tables, Columns and Rows
SQL Versions and Vendor Implementations
DDL – Creating and Managing Database Objects
DML – Retrieving and Managing Data
Sequences
Stored Procedures
Using SQL Terminals
2.
JDBC Fundamentals
What is the JDBC API?
JDBC Drivers
Making a Connection
Creating and Executing a Statement
Retrieving Values from a ResultSet
SQL and Java Datatypes
SQL NULL Versus Java null
Creating and Updating Tables
Handling SQL Exceptions and Proper Cleanup
Handling SQLWarning
3.
Advanced JDBC
SQL Escape Syntax
Using Prepared Statements
Using Callable Statements
Scrollable Result Sets
Updatable Result Sets
Transactions
Commits, Rollbacks, and Savepoints
Batch Processing
Alternatives to JDBC
4.
Introduction to Row Sets
Row Sets in GUI and J2EE programming
Advantages of RowSets
RowSet Specializations
Using CachedRowSets
Appendix A. Learning Resources
Appendix B. Course Schema
Appendix C. Methods and Types
System Requirements
Hardware – minimal: Pentium 500MHz, 256 meg RAM, 500 meg HD.
Hardware – recommended: Pentium 1.5gHz, 512 meg RAM, 1
gig HD. For Oracle systems,
significantly better processing power and memory is recommended – see Oracle’s
own documentation for this.
Operating system: Tested on Windows 2000 and XP
Professional editions. The course
software should be viable on all Windows or Linux systems which support J2SE
1.4.
Network: One
lab exercise on RMI requires network connections between student machines; no
Internet connection is required.
Software: All free downloadable tools, with an
option to use certain commercial products for the JDBC module. The course supports the following database
software:
·
Apache Derby 10 (formerly Cloudscape) – this
product is included with the course software and is the default
·
MySQL 4.1 – this is a free downloadable and the
Connector/J driver is included with the course software
·
Oracle 9i or 10g – no license or software is
included with the course