关于定义:什么是“Java Bean”?

What is a “Java Bean”?

本问题已经有最佳答案,请猛点这里访问。

这个名字真让我恼火。我希望有人能用我不会忘记的方式来解释这件事。)


serializable(任何Java库实现java.io.serializable类),具体如下:一个没有conventions argument的构造,通过使用得到的属性和accessors /是/集。

的想法是让它predictable属性,所以,etc自动发现可以通过反射的帮助在发展的工具和框架。


http:/ / / / javabean en.wikipedia.org维基

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 »

HTTP:/ / www.javalobby.org ALT文本/文章/ j2me在亚nutshell / coffeebeansingle.jpg


javabeans reusable软件是写在Java组件的组成部分。可以使用的工具和connected configured builder。三个关键特性,导致在任何Java类是成为一个大javabean

1
2
3
1.Class is serializable
2.class has a 0 argument constructor
3.class has getter and setter methods for data members

这里是一个简单的类,是有资格成为一个为javabean

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.io.*;

public class Student implements Serializable {

    private String name = null;

    //0 argument constructor
    public Student() {
    }
   //getter method
   public String getName() {
        return name;
   }
   //settor method
   public void setName(final String name) {
       this.name = value;
   }

}

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.

如果你已经使用摇摆的"按钮",那么你已经使用的一个组成部分(可见javabean)。你可以使用开发者工具(如豆大的netbeanside)变化是可用的"属性"。netbeans使用一些被称为"introspection"发现,javabean属性可以由用户coder /改进(例如名字,标题和文本-对于一个对齐按钮javabean摇摆组成部分)。你可以保存其状态(Beans的IDE也可能使用"/"serialization API允许使用的是这个)是另一个时间与你的最喜爱的设置。

不需要javabeans可见(像一个大秋千组成部分)。你可以创建你自己的javabean encrypt文本在一个大的clicks textbox当"好"按钮在一个安全的形式。你不看到你写的javabean不以为然,但其他一些API,可以使用"是的"encryption javabean在他们的代码与"产权"的一些变化,你是允许的(即公共encryption - type ="blowfish")。

群体, stejav


一个Java Bean是一个类,是serializable,有一个不argument的构造和使用方法,getters和setter为其成员国的领域。其使用在Java企业应用业务逻辑数据的大商店。


一个javabean是一个Java面向对象编程的satisfies conventions,如下:

  • javabean接口的类必须implement serializable
  • 的javabean类必须有一个不应该是公共的,arg构造
  • 所有javabean必须有公共属性和方法setter getter大集和得到所有Bean的属性。
  • 所有javabean instance variables应该是私人的和由getter和setter只访问。