A java bean is a software component that has been designed to be reusable in a variety of different environments.
Java bean is a reusable software component that can be visually manipulated in builder tools.
A java bean is a portable, plat from independent component model written in the java programming language, developed in collaboration with industry leaders.
It enables developers to write reusable components once and run them anywhere benefiting from the platform-independent power of java technology.
The goal of java beans is to create a system whereby application developers can take a set of beans from a stock library and wire them together to make a full application.
Features of JavaBeans:
1. Support for introspection
2. Support for customization
3. Support for events
4. Support for properties
5. Support for persistence
1. Support for introspection:
The builder tool discover a bean feature (properties, methods, events) by a process known as introspection.
Beans supports introspection in two ways:
- At the time of naming bean features, it provides support by adhering to specific rules, known as design pattern.
- It provides support by explicitly providing property, method and event information with a related bean information class.
2. Support for customization:
When we using application builder a user can customize the appearance and behaviour of a bean. Beans expose properties so that they can be customized at design time.
It support in 2 ways:
- Using property editors
- Using more sophisticated bean customizers.
3. Support for events:
Beans use events in order to communicate with other bean. Here the bean which wants to communicate is the source bean and bean that want to received event is the listener bean.
Two way of object involved-
- Source object
- Listener object
4. Support for properties :
This property is nothing but the bean appearance and behaviour characteristics, which can be changed at the run time. Both for customization and for programmatic use.
There are several types of properties : Simple, indexed, bound and constrained.
5. Support for persistence:
Bean can be customized in an application builder then have its customized state away and reloaded later.
Advantages of JavaBean:
1. Write once, run anywhere
2. It is just like as builder tool, can controlled, the properties, events and methods of a bean that are exposed to another application.
3. In the persistence storage, the configuration setting of a bean can be saved and restored the later.
4. Bean can communicate with other beans, a bean may register to receive events from other objects and can generate events that sent to the other objects.