JavaBeans are reusable Java components that can be manipulated visually in a builder tool.
JavaBeans is an architecture for both using and building components in Java. This architecture supports the features of software reuse, component models, and object orientation. One of the most important features of JavaBeans is that it does not alter the existing Java language. Java developers who are familiar with the language can use and create Beans without learning a new language.
Although Beans are intended to work in a visual application development tool, they don’t necessarily have a visual representation at run-time (although many will). What this does mean is that Beans must allow their property values to be changed through some type of visual interface, and their methods and events should be exposed so that the development tool can write code capable of manipulating the component when the application is executed.
Creating a Bean doesn’t require any advanced concepts. Here is some code that implements a simple Bean:
public class MyBean implements java.io.Serializable
{
protected int theValue;
public MyBean()
{
}
public void setMyValue(int newValue)
{
theValue = newValue;
}
public int getMyValue()
{
return theValue;
}
}
This is a Bean named MyBean that has state (the variable theValue) that will automatically be saved and restored by the JavaBeans persistence mechanism, and it has a property named MyValue that is usable by a visual programming environment. This Bean doesn’t have any visual representation, but that isn’t a requirement for a JavaBean component.
JavaSoft is using the slogan “Write once, use everywhere.” Of course “everywhere” means everywhere the Java run-time environment is available. What this means is that the entire run-time environment required by JavaBeans is part of the Java platform. No special libraries or classes have to be distributed with your components.
The JavaBeans class libraries provide a rich set of default behaviors for simple components (such as the one shown earlier). This means that you don’t have to spend your time building a lot of support for the Beans environment into your code.
opensource: del.icio.us tag/opensource
Ajax
tech
JavaBeans
serialization
converter
jsonlib
dynabeans