106. Advanced Java
Programming
Rev. 5.0
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 five modules. The first covers several general-purpose
topics: using Java-5.0 generics, writing multi-threaded applications, the
Reflection API and annotations, 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 Java Foundation Classes, or JFC, for
building graphical user interfaces (GUIs) for the presentation tier; Java RMI
as a way of distributing Java objects in a separate business tier; and JDBC for
the persistence tier. A J2SE multi-tier
application provides a comprehensive case study that illustrates multi-tier
architecture, design patterns, and best practices, and also provides a few
challenge labs. Students will complete
the course prepared to build distributed Java applications and to pursue JFC,
RMI, or JDBC in greater depth.
LEARNING OBJECTIVES
·
Make effective use of Java generic types.
·
Write multi-threaded Java applications.
·
Use the Reflection API for highly generic tasks,
discovery, or code-generation.
·
Use standard annotations and develop custom
annotations to express meta-data in Java source files.
·
Communicate between processes using network
sockets.
·
Understand the roles of JFC, RMI, JDBC, and
other Core API packages in the classic multi-tier architecture for distributed
systems.
·
Understand the basics of the JFC architecture.
·
Build complex GUIs using various JFC controls.
·
Understand the relationship between RMI and
various J2EE technologies such as JNDI, EJB, and CORBA.
·
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.
·
Use the Java 5.0 Core API and related tools to
develop robust multi-tier applications.
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. Generics
Using Generics
Type Erasure
Type Boundaries
Wildcards
Generic Methods
Strengths and Weaknesses of Generics
Legacy Code and Generics
2. Threads
Java Thread Model
Creating and Running Threads
Manipulating Thread
State
Thread Synchronization
Volatile Fields vs. Synchronized Methods
wait and notify
join and sleep
The Concurrency API
Atomic Operations
3. Reflection
Uses for Meta-Data
The Reflection API
The Class<T> Class
The java.lang.reflect Package
Reading Type Information
Navigating Inheritance Trees
Dynamic Instantiation
Dynamic Invocation
Reflecting on Generics
4. Annotations
Aspect-Oriented Programming and Java
The Annotations Model
Annotation Types and Annotations
Built-In Annotations
Annotations vs. Descriptors (XML)
5. 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. J2SE Multi-Tier
Case Study
1.
Overview
Three Tiers for J2EE
Three Tiers for J2SE
The Case Study
Design Patterns
Domain and Service Models
2.
The Presentation Tier
The Standalone/Client Application
JDesktopPane and JinternalFrame
Adapting JList, JTable, and JTree to Services
Presentation-Tier Patterns
3.
The Business Tier
Distributing the Application
A Chain of Services
Logging
Business-Tier Patterns
Designing for Latency
4.
The Persistence Tier
A Database is Not a Persistence Tier!
Persistence Frameworks
Persistent-Object Strategies
Persistence-Tier Patterns
Caching
Module 3. The Java
Foundation Classes
5.
Introduction to JFC
Abstract Windowing Toolkit Basics
Simple Layout Management
Simple Event Handling
Lightweight Controls
JFC Feature Set
JFC Architecture and Relationship to AWT
6.
JFC Application Design
Role of a JFrame
Building a Frame-Based JFC Application
Panes
Using Dialogs
7.
JFC Components
JFC Component Class Hierarchy
JComponent Features
Simple Control Types
Text Components
Menus
Managing Look and Feel
Module 4. Java Remote Method
Invocation
1.
RMI Architecture
Motivation for RMI
RMI, EJB, and CORBA
RMI Architecture
Lifetime of a Remote Method Invocation
Registries
Naming and URL Resolution
Interface Design
The Remote Interface
Implementation Classes
The RemoteObject and RemoteServer Classes
The UnicastRemoteObject Class
Server Implementation
Using the Registry
Client Implementation
Code Deployment
2.
Practical RMI
RMI Marshaling
Passing Objects
The Factory Pattern
Serialization vs. Remote Reference
Designing for Latency
The Transfer Object Pattern
Controlling Object Location
Exception Handling
Module 5. 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
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
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
5.0.
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.1 (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
·
PostgreSQL 8.0 for Windows – this is a free
downloadable and the JDBC driver is included with the course software