Java-Beans

 

 

 

Foreword

Resources

Code Listings

Foil Sets

Assignments

Solutions

External Resources

SiteMap

Search

Home

 

Java-Basics ] [ Java-Beans ] Java-RMI ] Java-CORBA ] Java-IDL ] Databases ] JDCE ] WebFlow ] Object WebFlow ] TVR ]

 

Development of reusable component architectures that will allow large software systems to be designed by combining components from possibly different sources is the intended goal of JavaBeans. JavaBeans provides mechanisms to define components in Java and specify interactions amongst them. Java Beans components provide support wherein component assemblers discover properties about components. One of the other interesting aspect about JavaBeans is that it also accommodates other component architectures such as OpenDoc, ActiveX and LiveConnect. So by writing to JavaBeans the developer is assured that the components can be used in these and other component architectures.

The bean that we present here is the Image-Editing bean detailed in Section 2.4.5.5 in the Java Chapter.

Source : (Image Editing Bean)

(a) sunw/demo/ImageEditor/ImageEditor.java
(b) sunw/demo/ImageEditor/FilterNameEditor.java
(c) sunw/demo/ImageEditor/ImageEditorBeanInfo.java

NOTE: A class that provides explicit information about a bean must implement the BeanInfo interface or extend a class that implements it. This interface identifies all of the methods that a framework needs in order to introspect a bean.

You specify the name of the bean info class by adding BeanInfo to the name of the bean. For example, the bean info class associated to the class ImageEditor must be named ImageEditorBeanInfo. The bean info class must be part of the same package as the bean itself.

(d) Resource files:

sunw/demo/ImageEditor/faces.gif,
sunw/demo/ImageEditor/ImageScaleIconColor16.gif,

sunw/demo/ImageEditor/ImageScaleIconColor32.gif,
sunw/demo/ImageEditor/ImageScaleIconMono16.gif,
sunw/demo/ImageEditor/ImageScaleIconMono32.gif

Makefile:
Compiling a bean is very similar to compiling a Java class. A bean, however, usually consists of more than one class: it can have an icon, a customizer, a BeanInfo class, and so on. Therefore, all of the bean class files and all other resource files must be packaged and delivered as a unit. JDK1.1 provides a utility, called Java archive (JAR), that supports the ZIP format and can bundle a number of files into one flat JAR file. Another complication when compiling a bean is the configuration management. Because a bean comprises more than one file, we need to ensure that proper versions of files are packaged together and that the JAR file is recreated whenever any of the bean's files changes. The best way to manage this complexity is through the use of makefiles.

ImageEditor.mk

JAR Files: Please refer to the Java-Basics section for more information on using JAR files.

ImageEditor.jar

 

Another Example: (TextEditor Bean)

Source
sunw/demo/TextEditor/TextEditor.java
sunw/demo/TextEditor/TextEditorBeanInfo.java
Makefile and JAR files
TextEditor.jar
TextEditor.mk