do we use java bean only to restrict user? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

do we use java bean only to restrict user?

• A Bean obtains all the benefits of Java’s “write-once, run-anywhere” paradigm. • The properties, events, and methods of a Bean that are exposed to another application can be controlled. • Auxiliary software can be provided to help configure a Bean. This software is only needed when the design-time parameters for that component are being set. It does not need to be included in the run-time environment. • The state of a Bean can be saved in persistent storage and restored at a later time. • A Bean may register to receive events from other objects and can generate events that are sent to other objects. java bean means only setter and getter method which helps to restrict user. i got 2nd point. But how can we get all others benefits which are mentioned here.

7th May 2017, 7:35 PM
Somnath Ghosh
Somnath Ghosh - avatar
1 Answer
0
Beans are well known approach, so applications expect them to be, this is the first point I guess. The third... well, clever IDE knows how to write getters amd setters, like you can auto-generare them from fields. Since there is a getter and a setter, you can read amd save the value anytime, and backup then reapply later on. As for events... methods can be used as lambda parameters and be stored as such. About how they generate messages... I don't know what it means for a bean to generate event. May a setter can trigger some inner mechanics, even triggering events, like a PropertyChangedEvent, which - of course - can be very handy.
21st Jun 2018, 11:00 AM
Magyar Dávid
Magyar Dávid - avatar