English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2006-07-13 05:15:38 · 3 answers · asked by niranjan d 1 in Computers & Internet Software

3 answers

A Java class is just your classic object-oriented programming language class. It is a template for creating objects.

A Java "Bean" is a class that is designed to be a "pluggable software component". As such there are a few simple rules that any class must follow to be a Bean:
- must be serializable (implements java.io.Serializable)
- properties must be accessible through public get*, set*, and is* methods
- must hava a no-argument constructor
- must implement event-handling methods as required by the component environment

The first three rules are not stressers. Serializable is a very commonly used marker interface. Most classes are written with a no-argument constructor unless there is a good reason not to. And, since the JavaBean standard was introduced, the get/set/is notation (setters and getters) has been almost universally accepted as a programming standard in most Java classes.

But that last restriction is the real kicker. A bean is designed to operate in a certain environment. As a GUI widget, as a workflow operation, as an control action responding to user input or activity. In any of these environments, or any other conceivable bean environment, beans communicate with each other and with the underlying environment via event-handling, which is a more sophisticated topic than I want to dive into right here. Most of the JavaBean API is given over to helping beans manage events of one form or another.

As mentioned elsewhere "Enterprise JavaBeans" (EJBs) are an entirely different animal, only loosely based on the 4 rules mentioned above. The bean environment for EJBs is called a "container". An EJB container requires a great many more programming restrictions than the few I mentioned above. Most notably (but barely scratching the surface): neither Thread creation (parallel execution) nor File I/O is allowed within an EJB.

2006-07-14 13:38:30 · answer #1 · answered by BalRog 5 · 1 0

The Java class is what you write your code in. The Java bean is a special kind of Java class that has to have certain specific methods.

While a Java class can be written for almost any general purpose, the Java bean class is meant to be written as a utility in a Java-based GUI tool.

Also note that an Enterprise Java Bean is something entirely different from these two.

2006-07-13 05:19:04 · answer #2 · answered by Zapata 2 · 0 1

ha ha

2016-03-27 03:51:22 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers