Beans in Java Programming

What are beans in Java programming? Is understanding Struts vital for Spring training?

+6
java
source share
5 answers

It depends.

You could talk about Spring beans, Enterprise Java Beans, or another option.

The general answer is that Beans is some type of general object (or POJO, possibly) that contains information - I almost think of them as my own data type. The difference is that they usually do not have a large number of behaviors, for example, they have only simple fields, getters, setters.

+5
source share

From Wikipedia :

JavaBeans is a reusable component software for Java that can be visually visualized in a builder tool. In practice, they are classes written in Java programming, a language corresponding to a certain convention. They are used to encapsulate many objects into a single object (bean) so that they can be transferred as a single bean object and not as several separate objects. JavaBean is a serializable Java object, has a null constructor, and allows access to properties using the getter and setter Methods.

+5
source share

The Java Bean is a class that conforms to the following convention:

  • The class must have an open default constructor (no argument). This makes it easy to create instances as part of editing and activation.
  • Class properties should be accessible using get, set, is (used for boolean properties instead of get) and other methods (the so-called access methods and mutator methods), following standard naming conventions. This makes it easy to automate checking and updating Bean status within the framework, many of which include custom editors for various types of properties.
  • The class must be serializable. This allows applications and frameworks to reliably save, save and restore the state of Bean in mod, regardless of the virtual machine and platform.

Source: Wikipedia .

+3
source share

A "bean" can be everything, depending on the context. Thus, it is roughly equivalent to an β€œobject”. (Note that this can also be considered equivalent to a "class", although I think it is more about cases than definitions. Therefore, a "bean class" is used more often)

  • a spring bean is any spring -managed object
  • javabean - an object of the class corresponding to the javabean spec (properties, getters and setters).
  • Enterprise java bean - container managed object

As for your second question - no, struts and spring are fairly separate technologies, and none of them require knowing the other.

+3
source share

Is understanding Struts vital for Spring training? No, both follow the MVC pattern, so knowing that the racks will help you learn spring .. but otherwise there are a lot of differences .. in how they work.

+1
source share

All Articles