Developing Java Beans

Book description

Java Beans is the most important new development in Java this year. Beans is the next generation of Java technology that not only adds features the language lacked, but also lets Java programs interoperate with a number of development environments. The initial release includes a bridge for Microsoft's ActiveX/COM; future releases will include bridges for Netscape's LiveConnect and IBM's OpenDoc. Since it's a "component architecture" for Java, Beans can be used in graphical programming environments, like Borland's JBuilder, or IBM's VisualAge for Java. This means that someone can use a graphical tool to connect a lot of Beans together and make an application, without actually writing any Java code -- in fact, without doing any programming at all. Graphical development environments let you configure components by specifying aspects of their visual appearance (like the color or label of a button) in addition to the interactions between components (what happens when you click on a button or select a menu item). One important aspect of Java Beans is that components don't have to be visible. This sounds like a minor distinction, but it's very important: the invisible parts of an application are the parts that do the work. So, for example, in addition to manipulating graphical widgets, like checkboxes and menus, Beans allows you to develop and manipulate components that do database access, perform computations, and so on. You can build entire applications by connecting pre-built components, without writing any code. Developing Java Beans is for people who need to stay up-to-date with the latest developments in programming technology. Minimally, developing Beans means adopting several simple design patterns in your code. However, that's only the beginning. To take full advantage of the Java Beans architecture, you should understand how to write classes that are serializable, use events for communication between classes, know when and how to provide BeanInfo classes that give graphical environments more information about your components, and provide property editors and customizers that let graphical tools work with more complex Beans. The book covers:

  • Events, event listeners, and adapters

  • Properties, indexed properties, bound properties, constrained properties, and vetoable property changes

  • Persistence, serialization, versioning, and object validation

  • Packaging Beans using JAR files

  • The BeanBox, a prototypical development tool

  • Reflection and introspection

  • Property editors and customizers

  • The ActiveX bridge; using Java Beans in Visual Basic programs

Table of contents

  1. Developing Java Beans
    1. Dedication
    2. Preface
      1. Intended Audience
      2. A Moment in Time
      3. How the Book Is Organized
      4. Conventions Used in This Book
      5. Acknowledgments
      6. How to Contact Us
      7. Providing Feedback to the Author
      8. Retrieving Examples Online
    3. 1. Introduction
      1. The Component Model
        1. Discovery and Registration
        2. Raising and Handling of Events
        3. Persistence
        4. Visual Presentation
        5. Support of Visual Programming
      2. The JavaBeans Architecture
        1. Compact and Easy
        2. Portable
        3. Leverages the Strengths of the Java Platform
        4. Flexible Build-Time Component Editors
      3. JavaBeans Overview
        1. Properties, Methods, and Events
        2. Introspection
        3. Customization
        4. Persistence
        5. Design-Time vs. Run-Time
        6. Visibility
        7. Multithreading
        8. Security
      4. Using Design Patterns
      5. JavaBeans vs. ActiveX
      6. Getting Started
    4. 2. Events
      1. The Java Event Model
        1. Event Objects
        2. Event Listeners
        3. Event Sources
        4. Event-Listener Methods with Multiple Parameters
        5. Unicast Event Propagation
        6. Exceptions
        7. Synchronous Event Delivery
        8. Multiple Threads
      2. Events in the AWT Package
    5. 3. Event Adapters
      1. Demultiplexing
        1. Adapter Classes
        2. Using Inner Classes
      2. Generic Adapters
        1. Using Java Reflection
          1. Finding the class
          2. Finding the method
        2. Single Instance Adapters
      3. Event Adapters in the AWT Package
        1. A Generic Button Adapter
      4. Event Filtering
      5. Event Queuing
    6. 4. Properties
      1. Accessing Properties
      2. Indexed Properties
      3. Bound Properties
        1. Non-Specific Property Binding
      4. Constrained Properties
        1. Binding to Non-Specific Constrained Properties
      5. Handling Events for Specific Properties
      6. A java.awt Example
    7. 5. Persistence
      1. Object Serialization
      2. The java.io.Serializable Interface
        1. Static Data Members
        2. Transient Data Members
        3. Implementing Serialization
      3. Class-Specific Serialization
      4. Walking the Class Hierarchy
      5. Serializing Event Listeners
      6. Versioning
        1. Stream Unique Identifiers
      7. Object Validation
      8. The java.io.Externalizable Interface
      9. Instantiating Serialized Objects
    8. 6. JAR Files
      1. The jar Program
      2. The Manifest
        1. Specifying a Manifest File
      3. Using JAR Files with HTML
        1. The ARCHIVES Attribute
      4. Using JAR Files on the CLASSPATH
      5. Archive Signing
      6. An Alternative to the jar Program
    9. 7. The BeanBox Tool
      1. Running BeanBox
      2. Dropping Beans on BeanBox
      3. Editing a Bean’s Properties
      4. Hooking Up Beans
      5. Saving and Restoring the BeanBox Form
      6. Adding Your Own Beans to BeanBox
        1. Using Your Beans in BeanBox
    10. 8. Putting It All Together
      1. Defining the Temperature Control Simulator
        1. The Temperature Object
        2. The Thermostat Object
        3. The Heating and Cooling Objects
        4. Significant Events
      2. Building the Simulator
        1. Temperature Pulse Events
        2. Service Request Events
        3. Property Change Events
        4. Temperature
        5. Coolers and Boilers
        6. The Thermostat
      3. A Sample Simulator Applet
      4. Creating a JAR File
      5. Recreating the Sample Using BeanBox
    11. 9. Introspection
      1. The BeanInfo Interface
        1. The Feature Descriptor
        2. The Bean Descriptor
        3. Icons
        4. Property Descriptors
        5. The Default Property
        6. Indexed Property Descriptors
        7. Method Descriptors
        8. Event Set Descriptors
        9. The Default Event Set
      2. Providing Additional BeanInfo Objects
        1. The Introspector
      3. Introspecting the Environment
        1. Design-time vs. Run-time
        2. Running Without a Graphical User Interface
        3. The Visibility Interface
      4. The BeansBook.SimulatorBeanInfo Classes
        1. The BeansBook.Simulator.TemperatureBeanInfo Class
        2. The BeansBook.Simulator.ThermostatBeanInfo Class
        3. The BeansBook.Simulator.BoilerBeanInfo Class
        4. The BeansBook.Simulator.CoolerBeanInfo Class
    12. 10. Property Editors and Customizers
      1. Property Editors
        1. Implementing the PropertyEditor Interface
        2. Locating Property Editors
          1. Registering a property editor
          2. Following a standard naming convention
          3. Looking in the default path
        3. Choosing an Appropriate Locator Technique
        4. Supporting Automatic Source Code Generation
      2. Customizers
    13. 11. ActiveX
      1. The JavaBeans ActiveX Bridge
        1. The Obstacles
        2. Packaging a Bean
      2. Technology Mapping
      3. Using Beans in Visual Basic
        1. Writing Code
    14. A. Design Patterns
      1. Event Objects
      2. Event Listeners
      3. Registering for Event Notification
      4. Registering for Unicast Event Notification
      5. Multiple Parameter Event Methods
      6. Property Access Methods
      7. Indexed Property Access Methods
      8. Constrained Property Access Methods
      9. Registering for Bound and Constrained Property Event Notifications
      10. Naming a BeanInfo Class
    15. B. The java.beans Package
      1. Class java.beans.BeanDescriptor
      2. Interface java.beans.BeanInfo
      3. Class java.beans.Beans
      4. Interface java.beans.Customizer
      5. Class java.beans.EventSetDescriptor
      6. Class java.beans.FeatureDescriptor
      7. Class java.beans.IndexedPropertyDescriptor
      8. Class java.beans.IntrospectionException
      9. Class java.beans.Introspector
      10. Class java.beans.MethodDescriptor
      11. Class java.beans.ParameterDescriptor
      12. Class java.beans.PropertyChangeEvent
      13. Interface java.beans.PropertyChangeListener
      14. Class java.beans.PropertyChangeSupport
      15. Class java.beans.PropertyDescriptor
      16. Interface java.beans.PropertyEditor
      17. Class java.beans.PropertyEditorManager
      18. Class java.beans.PropertyEditorSupport
      19. Class java.beans.PropertyVetoException
      20. Class java.beans.SimpleBeanInfo
      21. Interface java.beans.VetoableChangeListener
      22. Class java.beans.VetoableChangeSupport
      23. Interface java.beans.Visibility
    16. Index
    17. Colophon

Product information

  • Title: Developing Java Beans
  • Author(s): Robert Englander
  • Release date: June 1997
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781565922891