105. Using and Developing
JavaBeans
Rev. 1.3
This four-day course runs from an introduction to the JavaBeans
architecture through in-depth coverage of implementation techniques and issues.
The course taken as a whole is intended to give the student with no prior
JavaBeans experience (but a good working knowledge of the Java language) a firm
understanding of the component model, of how to use it in application
development by using predeveloped Beans, and of how to develop JavaBeans from
scratch. The course contains many example programs and exercises using the Bean
Development Kit (BDK).
The first module is an introduction to the JavaBeans component
model, to the builder tool – using the BDK’s BeanBox as a stand-in for a
commercial builder tool – and to practical issues of finding, understanding and
using JavaBeans as found on the market. This module concentrates on the use of
existing Beans in rapid application development. It is appropriate both for
programmers who want to develop JavaBeans, and as a standalone module for rapid
application developers who may not have Java coding experience but wish to use
existing JavaBeans in their work.
The second module focuses on requirements and techniques for
building JavaBeans from Java source code. It details the requirements of the
Beans specification in naming Beans features as public methods on a Java class.
The introspection process is liberally treated, including automatic analysis
and custom information using BeanInfo classes. Property editors and graphical customizers
are covered to conclude the module. Throughout, the BDK’s BeanBox is used as a
testing tool and also as an exemplar of the role a commercial Beans builder
tool plays in Beans development. Generated code from the BeanBox is dug up and
disassembled in a few cases as a way of investigating the importance of certain
standards and techniques.
LEARNING OBJECTIVES
·
Understand the Beans component model as a tool for
increasing productivity in software development and for enabling
interoperability with other vendors’ components.
·
Understand the role of a Beans builder tool in rapid
application development.
·
Learn the use of the tools provided by the BDK.
·
Use existing Beans for rapid application development of
Java programs.
·
Customize Beans by discovering and configuring their
properties.
·
Connect multiple Beans in a new application using
events, bound properties, and vetoable properties.
·
Learn how to design and to implement JavaBeans as Java
classes from scratch.
·
Implement properties, methods, and events.
·
Write code for Beans that will serialize and
deserialize correctly, by the correct use of transient and static fields, and
with deserialization code for proper initialization.
·
Build event adaptors to connect disparate Beans in an
application.
·
Build Beans software using visual tools, as Java
applets, or from code level as Java applications.
·
Use introspection to discover the details of a Bean’s
semantics.
·
Supply BeanInfo with a Bean to control the information
delivered to a client during introspection.
·
Provide customizers and specialized property sheets.
Course Duration: 4
days
Prerequisites: For
the first module the student should have a basic understanding of Java software
architecture (e.g. Module 1 from Object Innovations' Java Programming course).
Some experience with GUI building, perhaps in similar RAD environments, will be
helpful. The second module will require a good background in Java programming,
including object-oriented use of the language, GUI programming, and an
understanding of streams and serialization.
Module 1: Introduction to JavaBeans
1. The
JavaBeans Component Model
Overview
Role of a Bean
Life of a Bean
Properties
Methods
Events
Beans Standards in Other APIs
2. Builder
Tools and the BeanBox
The BeanBox
Design-time vs. Run-time
JARs, Manifests Identifying Beans
Adding Beans to a GUI
Binding Properties
Connecting via Events
Using Non-Visual Beans
Saving Boxes of Beans
3. Developing
Software Using Beans
Procuring Beans
Finding Out about a Bean
Exercising Beans
Beans in Applications
Generating an Applet
Module 2: JavaBeans Development
1. Implementing
JavaBeans
Defining Properties
Firing Events
Defining Event Handlers
JARring the Bean
Testing in the BeanBox
Bound Properties
Vetoable Properties
Bean Serialization
2. Events
in JavaBeans
Review of Java Event Model
Defining a Custom Event Class
Defining a Listener Interface
Implementing Event Source Behavior
Implementing an Event Handler
Events in the BeanBox
Generated Event Handlers – Some Sleuthing
Generated Connections in an Applet
3. Introspection
Introspection – Who Needs It?
Reflection – Summary
Instantiating a Bean
The Introspection Process
BeanInfo
Automatic Analysis
4. Providing
BeanInfo
Custom Profiles Using BeanInfo
Associating an Icon with a Bean
Simplifying the List of Methods
Feature Descriptors
Supporting Non-Standard Names
Additional BeanInfo
5. Customization
Property Sheets
Property Editors
Connection Using Property Views
Implementing a Property Editor
Customizers
The BeanDescriptor
Implementing a Customizer
Appendix A. References
Appendix B. Quick Reference: Beans Naming Conventions
System Requirements
Software:
·
Java Developer’s Kit version 1.4.
·
Beans Development Kit, version 1.1 or higher.
Hardware:
·
A Java2-capable PC or workstation per student