JavaBean Proxies

Using object proxies lets you access bean properties by name, augment the behavior of an object, and create a broker object of a JavaBean. Here's how to use them.

provided by: 
Originally published at Internet.com


While developing a small database application for keeping a work journal, I discovered I needed a way to map JavaBean properties to JTable columns. This led to creation of a component for accessing JavaBean properties by name at runtime - in other words, a JavaBean proxy. In this article, I illustrate my simple JavaBean proxy and show how JavaBean proxies can be created with the new dynamic proxy classes in JDK 1.3.

Tools



To use the code from this article, you will need the following tools:


(Note: For the simple bean proxy code, you can actually use JDK 1.2. You only need JDK 1.3 for the dynamic bean proxy code.)

Bean Interrogation



In order to access a JavaBean - or any java class for that matter - dynamically at runtime, you first need to get information about the capabilities of the class, or "class meta data". This information can come from two sources: BeanInfo classes and low-level analysis of the bean class. BeanInfo classes - extensions of java.beans.SimpleBeanInfo or implementations of java.beans.BeanInfo - provide descriptors of the properties, events, and methods of a class. They are associated with a class by the simple naming convention class name + "BeanInfo"...

Read article at Internet.com site

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML