JavaBeans
Encyclopedia : J : JA : JAV : JavaBeans
JavaBeans are software components written in the Java programming language.
The JavaBeans specification by Sun Microsystems defines them as "reusable software components that can be manipulated visually in a builder tool".
In spite of many similarities, JavaBeans should not be confused with Enterprise JavaBeans (EJB), a server-side component technology that is part of Java EE.
JavaBean conventions
In order to function as a JavaBean class, an object class must obey certain conventions about method naming, construction, and behavior. These conventions make it possible to have tools that can use, reuse, replace, and connect JavaBeans.The required conventions are:
- The class should be serializable (able to persistently save and restore its state)
- It should have a default constructor
- Its properties should be accessed using get, set and is methods that follow a standard naming convention
- It should contain any required event-handling methods
JavaBean Example
// PersonBean.javapublic class PersonBean implements java.io.Serializable
public String getName() public void setName(String name) // Different semantics for a boolean field (is vs. get) public boolean isDeceased() public void setDeceased(boolean deceased)}
// TestPersonBean.java}public class TestPersonBean
See also
- Widgets
- For a server side discussion of Java Beans see Enterprise JavaBeans.
External links
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
