GO-V.ORG
As seen in

JavaBeans

In computing based on the Java Platform, JavaBeans is a technology developed by Sun Microsystems and released in 1996, as part of JDK 1.1. The 'beans' of JavaBeans are classes that encapsulate one or more objects into a single standardized object (the bean). This standardization allows the beans to be handled in a more generic fashion, allowing easier code reuse and introspection. This in turn allows the beans to be treated as software components, and to be manipulated visually by editors and IDEs without needing any initial configuration, or to know any internal implementation details. As part of the standardization, all beans must be serializable, have a zero-argument constructor, and... Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.

In computing based on the Java Platform, JavaBeans is a technology developed by Sun Microsystems and released in 1996, as part of JDK 1.1. The 'beans' of JavaBeans are classes that encapsulate one or more objects into a single standardized object (the bean). This standardization allows the beans to be handled in a more generic fashion, allowing easier code reuse and introspection. This in turn allows the beans to be treated as software components, and to be manipulated visually by editors and IDEs without needing any initial configuration, or to know any internal implementation details. As part of the standardization, all beans must be serializable, have a zero-argument constructor, and allow access to properties using getter and setter methods. ==Features== Introspection Introspection is a process of analyzing a Bean to determine its capabilities. This is an essential feature of the Java Beans specification because it allows another application, such as a design tool, to obtain information about a component. Properties A property is a subset of a Bean's state. The values assigned to the properties determine the behaviour and appearance of that component. They are set through a setter method and can be obtained by a getter method. Customization A customizer can provide a step-by-step guide that the process must follow to use the component in a specific context. Events Beans may interact with the EventObject EventListener model. Persistence Persistence is the ability to save the current state of a Bean, including the values of a Bean's properties and instance variables, to nonvolatile storage and to retrieve them at a later time. Methods A Bean should use accessor methods to encapsulate the properties. A Bean can provide other methods for business logic not related to the access to the properties. ===Code example=== package org.wikipedia.players; import java.io.Serializable; import java.util.List; public class PersonBean implements Serializable { /** Properties **/ private boolean deceased = false; private List list; /** Property "name", readable/writable. */ private String name = null; /** No-arg constructor (takes no arguments). */ public PersonBean() { } public List getList() { return list; } public void setList(final List list) { this.list = list; } /** * Getter for property "name". */ public String getName() { return name; } /** * Setter for property "name". * * @param value */ public void setName(final String value) { this.name = value; } /** * Getter for property "deceased" * Different syntax for a boolean field (is vs get) */ public boolean isDeceased() { return deceased; } /** * Setter for property "deceased". * @param value */ public void setDeceased(boolean value) { deceased = value; } } TestPersonBean.java : package org.wikipedia.players; import java.util.ArrayList; import org.wikipedia.players.PersonBean; /** * Class "TestPersonBean". */ public class TestPersonBean { /** * Tester method "main" for class "PersonBean". * * @param arguments */ public static void main(String[] args) { final PersonBean person = new PersonBean(); person.setName("Bob"); person.setDeceased(false); person.setList(new ArrayList ()); // Output: "Bob is [alive]" System.out.printf("%s is %s%n", person.getName(), person.isDeceased() ? " [deceased]" : " [alive]"); } } Name: Deceased? Enter a name: Choose an option: Alive Dead ==References==

source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"JavaBeans". 1780092496. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1356814186

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·