What is a "Java Bean"?

This question already has an answer here:

  • What is a JavaBean exactly? 14 answers

  • Any serializable java class (implementing java.io.Serializable) that follows specific conventions: a no-argument constructor, and properties accessible via get/set/is accessors.

    The idea is to make it predictable, so that properties etc can be discovered automatically through reflection - of great help in tool and framework development.


    http://en.wikipedia.org/wiki/JavaBean

    JavaBeans are reusable software components for Java that can be manipulated visually in a builder tool. Practically, they are classes written in the Java programming language conforming to a particular convention. They are used to encapsulate many objects into a single object (the bean), so that they can be passed around as a single bean object instead of as multiple individual objects. A JavaBean is a Java Object that is serializable, has a nullary constructor, and allows access to properties using getter and setter methods.

    continue reading »

    alt text http://www.javalobby.org/articles/j2me-in-a-nutshell/CoffeeBeanSingle.jpg


    Sun's JavaBean Tutorial says...

    The JavaBeans™ architecture is based on a component model which enables developers to >create software units called components. Components are self-contained, reusable software units that can be visually assembled into composite components, applets, applications, and servlets using visual application builder tools. JavaBean components are known as beans.

    A set of APIs describes a component model for a particular language. The JavaBeans API specificationdescribes the core detailed elaboration for the JavaBeans component architecture.

    Beans are dynamic in that they can be changed or customized. Through the design mode of a builder tool you can use the Properties window of the bean to customize the bean and then save (persist) your beans using visual manipulation. You can select a bean from the toolbox, drop it into a form, modify its appearance and behavior, define its interaction with other beans, and combine it and other beans into an applet, application, or a new bean.

    If you've used Swing's 'button', then you've used a component (visible JavaBean). You can use developers tools (like NetbeansIDE) to change the Bean's available 'properties'. Netbeans uses something called 'introspection' to discover which JavaBean properties can be modified by the coder/user (eg name, text-title and alignment for a Swing Button JavaBean component). You can save its state too (the IDE/Beans developer might use 'serialization' to do this) allowing re-use with your favourite settings another time.

    JavaBeans don't need to be visible (like a swing component). You could create your own JavaBean to encrypt text in a textbox when someone clicks an 'OK' button on a form. You don't see your custom written JavaBean, but some other developer could re-use your 'encryption' JavaBean in their code with some 'property' changes that you allowed to be public (ie encryption-type="blowfish").

    Regards, SteJav

    链接地址: http://www.djcxy.com/p/47644.html

    上一篇: 如何在WebSphre集群环境中部署EAR文件?

    下一篇: 什么是“Java Bean”?