Bean Soup: Using Components With Java

Download Report

Transcript Bean Soup: Using Components With Java

Java 2 Overview
Alexander Day Chaffee
[email protected]
Purple Technology
http://www.purpletech.com/
Copyright © 1998 Alex Chaffee
Abstract
 Java
2 is a much-anticipated upgrade to
the Java platform that promises to
increase Java’s performance,
functionality, and security. But does it
live up to the hype? In this session we
provide an overview of the new features
and help you decide whether it’s in your
best interest to make the leap.
Copyright © 1998 Alex Chaffee
Introduction
 JGuru
Training from the MageLang
Institute
 http://www.jguru.com/
 Purple
Technology
 http://www.purpletech.com
 Alex
Chaffee
 Creator
of Gamelan
 Cool Java Dude
Copyright © 1998 Alex Chaffee
Overview
 Highlights
 History
and Compatibility
 Features, Features, Features
 Q&A
Copyright © 1998 Alex Chaffee
Highlights
 JFC
and Swing
 A framework
for building serious GUI
applications
 Collections
Framework
 A clean,
interface-based set of standard
data structures and algorithms (including
sorting!)
 Security
 Fine-grained,
cryptographic, ACL-based
Copyright © 1998 Alex Chaffee
security model
Highlights (Cont.)
 Enterprise
Java
 JDBC,
CORBA, JNDI, and RMI have all
been improved and are now "core"
 And
more!
 Reference
objects, Weak references,
performance enhancements, Standard
Extensions, Javadoc Doclets, ThreadLocal
variables, bug fixes, and improvements to
existing classes.
Copyright © 1998 Alex Chaffee
Should I Upgrade?
 Yes
Copyright © 1998 Alex Chaffee
Why should I upgrade?
 Stable
 New
features
 Backward-compatible
 Faster VM
Copyright © 1998 Alex Chaffee
A Brief Definition
 The
Java Development Environment
comprises
 The
Virtual Machine (VM)
 The Language
 The Core Libraries
 java.*,
javax.* classes
Copyright © 1998 Alex Chaffee
Java Development Kit
History
 Alpha,
Beta (1995)
 JDK 1.0 (Jan. 1996)
 JDK 1.1 (Feb. 1997)
 JDK 1.2, aka Java 2 (Dec. 1998)
Copyright © 1998 Alex Chaffee
JDK Evolution
 JDK
1.0 - VM Spec finalized
 JDK 1.1 - Language enhanced, core
libraries enhanced
 Inner
classes, reflection
 RMI, Events, Lightweight components
 JDK
1.2 (Java 2) - Primarily a library
and performance release
 No
major changes to language or VM
Copyright © 1998 Alex Chaffee
JDK Compatibility
 All
old features are available in JDK 1.2
 Most new features are compatible with
a JDK 1.1 environment
 You
can add the new classes to your
CLASSPATH
 Issues with some IDEs, e.g. VisualAge
 But there’s not much point -- just upgrade
to 1.2
Copyright © 1998 Alex Chaffee
Client-side Compatibility
 Java
was supposed to revolutionize
software distribution
 Surf
the web, download the latest version
of software
 Unfortunately,
there were problems
 Limited
Bandwidth
 Poor caching
 Java VM inside browser was never
updated
Copyright © 1998 Alex Chaffee
Java Plug-In (né Activator)
 Browser
VM automatically updated
 Three Major Flaws
 Plug-ins
Suck
 Large download
 Doesn’t override <APPLET> tag
 Need
to alter your page to use EMBED and
OBJECT tags
Copyright © 1998 Alex Chaffee
Java Plug-In (Cont.)
 When
it works
 Intranet
software distribution
Copyright © 1998 Alex Chaffee
Java 2 Features
Copyright © 1998 Alex Chaffee
Swing
 Radical
rewrite of widget set
 Basic AWT classes still used
 Window,
Graphics, Image
 Everything
 JButton,
else rewritten
JFrame, JLabel…
Copyright © 1998 Alex Chaffee
AWT = Peer Architecture
 Each
widget does not draw itself
 Possesses
a “peer” object
 Peer interacts with native OS widgets
 Native OS widgets do drawing and event
handling
 Two
major problems
 Impossible
to extend widgets (subclass)
 Different behavior on different platforms
 Look
different, act different, different bugs
Copyright © 1998 Alex Chaffee
Swing = Lightweight
 All
widgets are 100% Pure Java
 No
peers
 Use Graphics to draw
 “J”
versions of all the basic widgets
 JButton,
JFrame, JList, etc.
Copyright © 1998 Alex Chaffee
Swing = Consistent
 All
widgets share common functionality
 Double-buffered
 Tooltips
 Extensible
via subclass
 Track the tab key for focus
 Support keyboard shortcuts
 Internationalizable
Copyright © 1998 Alex Chaffee
Swing = Consistent (cont.)
 JButtons
 Built
and JLabels can contain icons
from GIF files
 JPanels
can have standard borders
 JMenus and JMenuBars can be added
to any container
Copyright © 1998 Alex Chaffee
New Swing Widgets
 JTree
 Hierarchical
list
 JTable
 Row-column
spreadsheet
 Resizable / moveable columns
Copyright © 1998 Alex Chaffee
Swing Widgets (cont.)
 JScrollPane
 You
can scroll any component or container,
just by adding it to the JScrollPane
 JToolbar
 Floatable
panel containing little icons
 JEditorPane
 Styled
text editor
 Fully functional HTML renderer (!!!)
Copyright © 1998 Alex Chaffee
BoxLayout
 Straightforward
layout manager
 Left-to-right or top-to-bottom
 Glue / rigid areas
 Nestable
 Can
create any rectangular partition of the
screen
Copyright © 1998 Alex Chaffee
Swing Design Concepts

MVC
 Can
use your own data models for any widget
 E.g. use a database to back a Jtable
 Pluggable
Look And Feel (“PLAF”)
 Masquerade

Action
 Decouples

as Macintosh or Windows app
functionality from widgets
Events and Java Beans
 Uses
JDK1.1 standards
Copyright © 1998 Alex Chaffee
JFC vs. Swing
 JFC
= Swing plus Drag-and-drop plus
Java2D plus Accessibility plus some
other miscellaneous services (like
Keyboard Navigation and Undo).
 Swing is in JFC, but JFC is not Swing
Copyright © 1998 Alex Chaffee
JFC
 Drag-and-drop
 And
copy-and-paste
 Java2D
 Fancy
graphics - scaling, rotating, fonts
 Reportedly a little buggy
 Accessibility
 Disabled
users (blind, deaf, etc.)
Copyright © 1998 Alex Chaffee
JavaBeans Enhancements
 Interaction
with Applet Semantics
 Better Design-Time Support
 JavaBeans Runtime Containment and
Services Protocol
Copyright © 1998 Alex Chaffee
Audio Enhancements
 Java
Sound API
 getNewAudioClip Method
Copyright © 1998 Alex Chaffee
Collections Framework
Copyright © 1998 Alex Chaffee
31
Abstract Data Types
 Data
Structures and Algorithms
 Standard
 Well-understood
 Efficient
 Examples
 Stack,
1.0t
queue, linked list
Copyright © 1998 Purple Technology, In
32
Interface-based design
 Separate
interface from implementation
 Built in to Java language
 Polymorphism

List l = new LinkedList();
 Calling l.add()
invokes method of class
LinkedList
1.0t
Copyright © 1998 Purple Technology, In
33
Collections Framework
 Interoperability
between unrelated APIs
 Reduces the effort required to learn APIs
 Reduces the effort required to design
and implement APIs
 Fosters software reuse
1.0t
Copyright © 1998 Purple Technology, In
34
Project Goals
 Small API
 Number
of interfaces
 Number of methods per interface
 Low "conceptual weight"
 Builds
on existing Java collections
(Vector, Hashtable)
 Interconvertible with Java arrays
1.0t
Copyright © 1998 Purple Technology, In
35
Overview: Core Interfaces
 Collection
 Set
 List
 Map
 SortedSet
 SortedMap
1.0t
Copyright © 1998 Purple Technology, In
Enterprise Java
 Java
being pushed to become the
standard for Enterprise Computing.
 Large companies
 Large, distributed, reliable, scalable,
high-performance, database-driven,
transaction-aware, 24-7 monsters- um, that is, programs
Copyright © 1998 Alex Chaffee
Enterprise Java Elements
 CORBA (JavaIDL)
 Now
a core package
 Java2 ships with 100% Pure Java ORB
 RMI
 Custom
sockets (SSL, IIOP)
 Remote object activation
Copyright © 1998 Alex Chaffee
Enterprise Java (cont.)
 Transactions
(OTS/JTS)
 Distributed
transaction support
 Compatible with CORBA standard
 JDBC
improved
 scrollable
and updatable result sets, batch
updates, connection pooling, rowsets (sort
of Bean-enabled database view), distibuted
transactions, extra data types, etc.
Copyright © 1998 Alex Chaffee
Enterprise Java Beans
 Not
technically part of Java2 release
 Common API for developing business
components
 Live inside special EJB servers
 Vendor-independent
 100% Pure Java
 Distributed transactions
 Security
Copyright © 1998 Alex Chaffee
Java2 Security
 More
than a sandbox
 New system based on permissions,
identity, and access-control lists (ACLs)
Copyright © 1998 Alex Chaffee
Policy and Permission
 Security
Manager delegates to Policy
object
 Policy consults Policy File
 Grants (or denies) Permissions based
on
 Where
the code came from (the code
base)
 Who wrote the code (the code signature)
 Easily
extensible
Copyright © 1998 Alex Chaffee
Policy Usage
 Can
edit policy file or use policytool app
 Examples
a
user may decide to allow trusted applets
to save files to particular directories
 more control over network-loaded code;
this will be of particular interest to
distributed Java efforts such as RMI and
Jini.
Copyright © 1998 Alex Chaffee
Crypto
 Support
for public/private key algorithms
 keytool for managing key databases,
jarsigner for signing code
 X.509 implementation
 JCE for extensions
 Only
available in US and Canada
 Third parties are implementing outside US
(and its draconian export laws)
Copyright © 1998 Alex Chaffee
Java Crypto UI
 Lame
 No
GUI for keytool
 Scary GUI for policytool
 Therefore, Java Crypto is good for
programmers, not (yet) for users
Copyright © 1998 Alex Chaffee
Performance
Enhancements
 Solaris
Native Thread Support
 Memory Compression for Loaded
Classes
 Faster Memory Allocation and Garbage
Collection
 Monitor Speedups
 Native Library JNI Port
 JIT Compilers
Copyright © 1998 Alex Chaffee
Other Enhancements








Version Identification
Reference Objects (including weak references)
Extensions Framework
Input Method Framework
Improvements to JAR, JNI, Redlection, JDBC-ODBC
Bridge
Servlets (a standard extension)
Javadoc Doclets (a tool)
Java Virtual Machine Debug Interface
Copyright © 1998 Alex Chaffee
Conclusion
Copyright © 1998 Alex Chaffee
Where to Get More
Information:

Web sites
 http://www.Developer.com/
(Gamelan)
 http://www.JavaWorld.com/ (magazine)
 http://www.Purpletech.com/ (author’s site)
 http://www.alphaworks.ibm.com/alphaBeans
Copyright © 1998 Alex Chaffee
Credits

Thanks to Nelson Minar for research and
assistance
Copyright © 1998 Alex Chaffee