SlideShare a Scribd company logo
JavaBeans
Definition: A Java Bean is a reusable software
component that can be manipulated visually in a
builder tool.
a software component model
Software components are self-contained software
units developed according to the motto.
Developed them once, run and reused them
everywhere.
A Java Bean is an ordinary java class that confirms the
following rules
1. It provides a default, no-argument constructor.
2. It should be serializable and implement the
Serializable interface.
3. It may have a number of properties which can be
read or written.
4. It may have a number of "getter" and "setter"
methods for accessing properties.
Advantages of Java Beans
1. Beans is platform independent, that means it can
be run anywhere.
2. Beans can work in different local platforms.
3. Methods, properties and events of Beans can be
controlled.
4. It is easy to configure Java beans
5. A bean can both receive and create events
6. Configuration settings of a bean can be stored
persistently and can be retrieved any time
How to write a java bean using coding standards
public class StudentsBean implements java.io.Serializable
{
private String firstName = null;
private String lastName = null;
public StudentsBean() { }
public String getFirstName()
{
return firstName;
}
public String getLastName()
{
return lastName;
}
public void setFirstName(String firstName)
{
this.firstName = firstName;
}
public void setLastName(String lastName)
{
this.lastName = lastName; }
}
Bean Development Kit(BDK)
BDK is a development tool through which java beans can be
created, configured, executed or interconnected.
Installation
C:beans
Bean box
Run.bat
Starting the BeanBox
When you start the BeanBox, you'll see three
windows:
– ToolBox window
– BeanBox window
– Properties window
Java beans
• The ToolBox window displays the JavaBeans
that are currently installed in the BeanBox
• The BeanBox window itself appears initially as
an empty window.
• the Properties window, displays the current
properties for the selected Bean
• Method tracer, used to keep an eye on the
activities of bean,mainly used for debugging
purpose.
Create and Configure an Instance of
the Molecule Bean
• Follow these steps
1. Position the cursor on the ToolBox entry labeled
Molecule and click the left mouse button.
2. Move the cursor to the BeanBox display area and
click the left mouse button.
3. You can reposition the Molecule Bean by
positioning the cursor over one of the hatched
borders and dragging the Bean.
4. You can change the molecule that is displayed by
changing the selection in the Properties window
Java beans
Instrospection
• builder tools typically provide a property sheet
where one can conveniently set the properties of a
JavaBean component.
• In order to provide this service a builder tool needs
to examine the component for its features
(=properties, events and methods).This process is
referred to as “introspection”.
• Introspection is the automatic process of analyzing
a bean's design patterns to reveal the bean's
properties, events, and methods. This process
controls the publishing and discovery of bean
operations and properties.
• To obtain information about a specific JavaBean one
can use the static getBeanInfo() method of the
Introspector class.
• This method returns an instance of the BeanInfo
class, which describes all features a JavaBean
exposes.
• use of this method is shown in the following code
fragment:
FontSelector fs = new FontSelector ();
BeanInfo bi = Introspector . getBeanInfo (fs.
getClass ());
The following example represents code to perform introspection:
• import java.beans.BeanInfo;
• import java.beans.Introspector;
• import java.beans.IntrospectionException;
• import java.beans.PropertyDescriptor;
• public class BeanDemo
• {
• private final String name = "BeanDemo";
• private int size;
• public String getName()
• {
• return this.name;
• }
• public int getSize()
• {
• return this.size;
• }
• public void setSize( int size )
• {
• this.size = size;
• }
• public static void main( String[] args )
• throws IntrospectionException
• {
• BeanInfo info = Introspector.getBeanInfo( BeanDemo.class );
• for ( PropertyDescriptor pd : info.getPropertyDescriptors() )
• System.out.println( pd.getName() );
• }
• }
• The above example creates a non-visual bean
displays the following properties derived from
the BeanInfo object.
out put:
class
name
size
BeanInfo Interface
• A bean implementor who wishes to provide explicit
information about their bean may provide a BeanInfo
class that implements this BeanInfo interface and
provides explicit information about the methods,
properties, events, etc, of their bean.
Method Detail
• getBeanDescriptor
public BeanDescriptor getBeanDescriptor()
Gets the beans BeanDescriptor.
Returns:A BeanDescriptor providing overall
information about the bean
• getEventSetDescriptors
public EventSetDescriptor[] getEventSetDescriptors()
Gets the beans EventSetDescriptors.
Returns:An array of EventSetDescriptors
describing the kinds of events fired by this
bean
• getDefaultEventIndex
• public int getDefaultEventIndex()
• A bean may have a "default" event that is the
event that will mostly commonly be used by
humans when using the bean.
Returns:Index of default event in the
EventSetDescriptor array returned by
getEventSetDescriptors.Returns -1 if there is
no default event.
• getPropertyDescriptors
• public PropertyDescriptor[] getPropertyDescriptors()
Gets the beans PropertyDescriptors.
Returns:An array of PropertyDescriptors
describing the editable properties supported
by this bean.
• getDefaultPropertyIndex
• public int getDefaultPropertyIndex()
• A bean may have a "default" property that is the
property that will mostly commonly be initially
chosen for update by human's who are customizing
the bean.
• Returns:Index of default property in the
PropertyDescriptor array returned by
getPropertyDescriptors.Returns -1 if there is no
default property.
• getMethodDescriptors
• public MethodDescriptor[] getMethodDescriptors()
• Gets the beans MethodDescriptors.
• Returns:An array of MethodDescriptors
describing the externally visible methods
supported by this bean
• getAdditionalBeanInfo
public BeanInfo[] getAdditionalBeanInfo()
that provide additional information on the
current bean
• getIcon
public Image getIcon(int iconKind)
This method returns an image object that can
be used to represent the bean in toolboxes
Properties
• There exist four different kinds of properties a
JavaBean can expose:
1. Simple
2. Indexed
3. Bound
4. Constrained
• All types of property have in common that
they are characterized by a pair of set/get
methods.
Simple Properties
• As the name suggests, simple properties are
the simplest of the four.
• we would like to have a default font size,
which will be used as initial font size at
runtime.
• Design patterns, where N is the name of the
property and T is its type.
public T getN( );
public void setN(T arg);
The following listing shows a class that has three read/write simple
properties:
• public class Box {
• private double depth, height, width;
• public double getDepth( ) {
• return depth;
• }
• public void setDepth(double d) {
• depth = d;
• }
• public double getHeight( ) {
• return height;
• }
• public void setHeight(double h) {
• height = h;
• }
• public double getWidth( ) {
• return width;
• }
• public void setWidth(double w) {
• width = w;
• }
• }
Indexed Properties
• If a simple property can hold an array of value
they are no longer called simple but instead
indexed properties
• An indexed property may expose set/get
methods to read/write one element in the
array and/or so-called ’array getter/setter’
which read/write the entire array.
• design patterns, where N is the name of the
property and T is its type:
– public T getN(int index);
– public void setN(int index, T value);
– public T[ ] getN( );
– public void setN(T values[ ]);
• The following listing shows a class that has one read/write indexed
property:
• public class PieChart {
• private double data[ ];
• public double getData(int index) {
• return data[index];
• }
• public void setData(int index, double value) {
• data[index] = value;
• }
• public double[ ] getData( ) {
• return data;
• }
• public void setData(double[ ] values) {
• data = new double[values.length];
• System.arraycopy(values, 0, data, 0, values.length);
• }
• }
Bound Properties
• A Bean that has a bound property generates an
event when the property is changed.
• Bound Properties are the properties of a JavaBean
that inform its listeners about changes in its values.
• Bound Properties are implemented using the
PropertyChangeSupport class and its methods.
• Bound Properties are always registered with an
external event listener.
• The event is of type PropertyChangeEvent and is sent to
objects that previously registered an interest in receiving such
notifications.
• In order to provide this notification service a JavaBean needs
to have the following two methods:
public void
addPropertyChangeListener(PropertyChangeListener p)
{
changes.addPropertyChangeListener(p);
}
public void
removePropertyChangeListener(PropertyChangeListener p)
{
changes.removePropertyChangeListener(p);
}
Constrained Properties
• A Bean that has a constrained property generates
an event when an attempt is made to change its
value.
• Constrained Properties are implemented using the
PropertyChangeEvent class.
• The event is sent to objects that previously
registered an interest in receiving such notifications.
Those other objects have the ability to veto the
proposed change. This capability allows a Bean to
operate differently according to its run-time
environment.
• Constrained Properties are the properties that are
protected from being changed by other JavaBeans.
• Constrained Properties are registered with an external
event listener that has the ability to either accept or
reject the change in the value of a constrained
property.
• Constrained Properties can be retrieved using the get
method. The prototype of the get method is:
• Syntax:
public string get<ConstrainedPropertyName>()
• Can be specified using the set method. The prototype
of the set method is:
• Syntax:
Public string set<ConstrainedPropertyName>(String
str)throws PropertyVetoException
Persistence
• Persistence is the ability to save a Bean to
nonvolatile storage and retrieve it at a later
time.
• Inorder to do this we take the help of BDK.
Saving the beans in the BDK :choose “file”
and then the “save” options.
Restoring the beans in the BDK:choose “file”
and then “load ” options.
The Java Beans API
• The Java Beans functionality is provided by a
set of classes and interfaces in the
java.beans package.
Interface Description
AppletInitializer Methods in this interface are used to
initialize Beans that are also applets.
BeanInfo This interface allows a designer to specify
information about the properties, events,
and methods of a Bean.
Customizer This interface allows a designer to provide
a graphical user interface through which a
Bean may be configured.
ExceptionListener A method in this interface is invoked
when an exception has occurred
PropertyChangeListener A method in this interface is invoked
when a bound property is changed.
PropertyEditor Objects that implement this interface
allow designers to change and display
property values
Interface Description
VetoableChangeListener A method in this interface is invoked
when a constrained property is changed.
Visibility Methods in this interface allow a Bean to
execute in environments where a
graphical user interface is not available.
Class Description
Encoder Encodes the state of a set of Beans. Can
be used to write this information to a
stream
EventHandler Supports dynamic event listener creation
EventSetDescriptor Instances of this class describe an event
that can be generated by a Bean
FeatureDescriptor This is the superclass of the
PropertyDescriptor,
EventSetDescriptor, and
MethodDescriptor
classes.
IndexedPropertyDescriptor Instances of this class describe an indexed
property of a Bean.
SimpleBeanInfo This class provides functionality that can
be used when writing BeanInfo classes
Class description
IntrospectionException An exception of this type is generated if a
problem occurs when analyzing a Bean.
Introspector This class analyzes a Bean and constructs
a BeanInfo object that describes the
component
MethodDescriptor Instances of this class describe a method
of a Bean.
ParameterDescriptor Instances of this class describe a method
parameter.
PropertyChangeEvent This event is generated when bound or
constrained
properties are changed
PropertyDescriptor Instances of this class describe a property
of a Bean.
PropertyEditorManager This class locates a PropertyEditor object
for agiven type.
Ad

More Related Content

What's hot (20)

enterprise java bean
enterprise java beanenterprise java bean
enterprise java bean
Jitender Singh Lodhi
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
Aneega
 
Introduction to java beans
Introduction to java beansIntroduction to java beans
Introduction to java beans
Hitesh Parmar
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
ShahDhruv21
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
Zeeshan Ahmed
 
Java beans
Java beansJava beans
Java beans
sptatslide
 
Servlet life cycle
Servlet life cycleServlet life cycle
Servlet life cycle
Venkateswara Rao N
 
Event handling
Event handlingEvent handling
Event handling
swapnac12
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
priya Nithya
 
Java Collections
Java  Collections Java  Collections
Java Collections
Kongu Engineering College, Perundurai, Erode
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
Tanmoy Barman
 
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in java
CPD INDIA
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
Google
 
Dom
DomDom
Dom
Rakshita Upadhyay
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
Vikas Jagtap
 
Struts framework
Struts frameworkStruts framework
Struts framework
baabtra.com - No. 1 supplier of quality freshers
 
Servlets
ServletsServlets
Servlets
Rajkiran Mummadi
 
Java thread life cycle
Java thread life cycleJava thread life cycle
Java thread life cycle
Archana Gopinath
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
Event handling
Event handlingEvent handling
Event handling
Shree M.L.Kakadiya MCA mahila college, Amreli
 

Similar to Java beans (20)

Javabean1
Javabean1Javabean1
Javabean1
Saransh Garg
 
Unit4wt
Unit4wtUnit4wt
Unit4wt
vamsi krishna
 
Unit4wt
Unit4wtUnit4wt
Unit4wt
vamsitricks
 
Java Beans Unit 4(part 2)
Java Beans Unit 4(part 2)Java Beans Unit 4(part 2)
Java Beans Unit 4(part 2)
Dr. SURBHI SAROHA
 
Unit iv
Unit ivUnit iv
Unit iv
bhushan_adavi
 
web programmimg- concpt in JAVABEANS.ppt
web programmimg- concpt in JAVABEANS.pptweb programmimg- concpt in JAVABEANS.ppt
web programmimg- concpt in JAVABEANS.ppt
mcjaya2024
 
WEB PROGRAMMING UNIT IV NOTES BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT IV NOTES BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT IV NOTES BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT IV NOTES BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
Java beans
Java beansJava beans
Java beans
Ramraj Choudhary
 
CommercialSystemsBahman.ppt
CommercialSystemsBahman.pptCommercialSystemsBahman.ppt
CommercialSystemsBahman.ppt
KalsoomTahir2
 
Java beans
Java beansJava beans
Java beans
Mukesh Tekwani
 
introduction of Java beans
introduction of Java beansintroduction of Java beans
introduction of Java beans
shravan kumar upadhayay
 
Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2
Fahad Golra
 
Java beans
Java beansJava beans
Java beans
Umair Liaqat
 
React-Native Lecture 11: In App Storage
React-Native Lecture 11: In App StorageReact-Native Lecture 11: In App Storage
React-Native Lecture 11: In App Storage
Kobkrit Viriyayudhakorn
 
Introduction of Life Cycle.pptx
Introduction of Life Cycle.pptxIntroduction of Life Cycle.pptx
Introduction of Life Cycle.pptx
fake621211
 
Bean Intro
Bean IntroBean Intro
Bean Intro
vikram singh
 
Session 5 Tp5
Session 5 Tp5Session 5 Tp5
Session 5 Tp5
phanleson
 
Java Beans Unit 4(Part 1)
Java Beans Unit 4(Part 1)Java Beans Unit 4(Part 1)
Java Beans Unit 4(Part 1)
Dr. SURBHI SAROHA
 
Classes, Inheritance ,Packages & Interfaces.pptx
Classes, Inheritance ,Packages & Interfaces.pptxClasses, Inheritance ,Packages & Interfaces.pptx
Classes, Inheritance ,Packages & Interfaces.pptx
DivyaKS18
 
Spring essentials 2 Spring Series 02)
Spring essentials 2 Spring Series 02)Spring essentials 2 Spring Series 02)
Spring essentials 2 Spring Series 02)
Heartin Jacob
 
web programmimg- concpt in JAVABEANS.ppt
web programmimg- concpt in JAVABEANS.pptweb programmimg- concpt in JAVABEANS.ppt
web programmimg- concpt in JAVABEANS.ppt
mcjaya2024
 
WEB PROGRAMMING UNIT IV NOTES BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT IV NOTES BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT IV NOTES BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT IV NOTES BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
CommercialSystemsBahman.ppt
CommercialSystemsBahman.pptCommercialSystemsBahman.ppt
CommercialSystemsBahman.ppt
KalsoomTahir2
 
Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2Lecture 9 - Java Persistence, JPA 2
Lecture 9 - Java Persistence, JPA 2
Fahad Golra
 
Introduction of Life Cycle.pptx
Introduction of Life Cycle.pptxIntroduction of Life Cycle.pptx
Introduction of Life Cycle.pptx
fake621211
 
Session 5 Tp5
Session 5 Tp5Session 5 Tp5
Session 5 Tp5
phanleson
 
Classes, Inheritance ,Packages & Interfaces.pptx
Classes, Inheritance ,Packages & Interfaces.pptxClasses, Inheritance ,Packages & Interfaces.pptx
Classes, Inheritance ,Packages & Interfaces.pptx
DivyaKS18
 
Spring essentials 2 Spring Series 02)
Spring essentials 2 Spring Series 02)Spring essentials 2 Spring Series 02)
Spring essentials 2 Spring Series 02)
Heartin Jacob
 
Ad

More from Rajkiran Mummadi (16)

Php
PhpPhp
Php
Rajkiran Mummadi
 
Javabeans .pdf
Javabeans .pdfJavabeans .pdf
Javabeans .pdf
Rajkiran Mummadi
 
Java script
Java scriptJava script
Java script
Rajkiran Mummadi
 
Ajax.pdf
Ajax.pdfAjax.pdf
Ajax.pdf
Rajkiran Mummadi
 
Google glasses
Google glassesGoogle glasses
Google glasses
Rajkiran Mummadi
 
Environmental hazards
Environmental hazardsEnvironmental hazards
Environmental hazards
Rajkiran Mummadi
 
Wcharging
WchargingWcharging
Wcharging
Rajkiran Mummadi
 
Wireless charging
Wireless chargingWireless charging
Wireless charging
Rajkiran Mummadi
 
Standard bop
Standard bopStandard bop
Standard bop
Rajkiran Mummadi
 
Russian technology in indian banking system 1
Russian technology in indian banking system 1Russian technology in indian banking system 1
Russian technology in indian banking system 1
Rajkiran Mummadi
 
Ai presentation
Ai presentationAi presentation
Ai presentation
Rajkiran Mummadi
 
Loon
LoonLoon
Loon
Rajkiran Mummadi
 
Triggers
TriggersTriggers
Triggers
Rajkiran Mummadi
 
autonomous cars
autonomous carsautonomous cars
autonomous cars
Rajkiran Mummadi
 
ET3
ET3ET3
ET3
Rajkiran Mummadi
 
demonetisation
demonetisationdemonetisation
demonetisation
Rajkiran Mummadi
 
Ad

Recently uploaded (20)

Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
 
Salesforce AI Associate 2 of 2 Certification.docx
Salesforce AI Associate 2 of 2 Certification.docxSalesforce AI Associate 2 of 2 Certification.docx
Salesforce AI Associate 2 of 2 Certification.docx
José Enrique López Rivera
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from AnywhereAutomation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Lynda Kane
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
 
Hands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordDataHands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordData
Lynda Kane
 
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersAutomation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Lynda Kane
 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
 
Salesforce AI Associate 2 of 2 Certification.docx
Salesforce AI Associate 2 of 2 Certification.docxSalesforce AI Associate 2 of 2 Certification.docx
Salesforce AI Associate 2 of 2 Certification.docx
José Enrique López Rivera
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from AnywhereAutomation Hour 1/28/2022: Capture User Feedback from Anywhere
Automation Hour 1/28/2022: Capture User Feedback from Anywhere
Lynda Kane
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
 
Hands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordDataHands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordData
Lynda Kane
 
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersAutomation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Lynda Kane
 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 

Java beans

  • 1. JavaBeans Definition: A Java Bean is a reusable software component that can be manipulated visually in a builder tool. a software component model Software components are self-contained software units developed according to the motto. Developed them once, run and reused them everywhere.
  • 2. A Java Bean is an ordinary java class that confirms the following rules 1. It provides a default, no-argument constructor. 2. It should be serializable and implement the Serializable interface. 3. It may have a number of properties which can be read or written. 4. It may have a number of "getter" and "setter" methods for accessing properties.
  • 3. Advantages of Java Beans 1. Beans is platform independent, that means it can be run anywhere. 2. Beans can work in different local platforms. 3. Methods, properties and events of Beans can be controlled. 4. It is easy to configure Java beans 5. A bean can both receive and create events 6. Configuration settings of a bean can be stored persistently and can be retrieved any time
  • 4. How to write a java bean using coding standards public class StudentsBean implements java.io.Serializable { private String firstName = null; private String lastName = null; public StudentsBean() { } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public void setFirstName(String firstName) { this.firstName = firstName; } public void setLastName(String lastName) { this.lastName = lastName; } }
  • 5. Bean Development Kit(BDK) BDK is a development tool through which java beans can be created, configured, executed or interconnected. Installation C:beans Bean box Run.bat
  • 6. Starting the BeanBox When you start the BeanBox, you'll see three windows: – ToolBox window – BeanBox window – Properties window
  • 8. • The ToolBox window displays the JavaBeans that are currently installed in the BeanBox • The BeanBox window itself appears initially as an empty window. • the Properties window, displays the current properties for the selected Bean • Method tracer, used to keep an eye on the activities of bean,mainly used for debugging purpose.
  • 9. Create and Configure an Instance of the Molecule Bean • Follow these steps 1. Position the cursor on the ToolBox entry labeled Molecule and click the left mouse button. 2. Move the cursor to the BeanBox display area and click the left mouse button. 3. You can reposition the Molecule Bean by positioning the cursor over one of the hatched borders and dragging the Bean. 4. You can change the molecule that is displayed by changing the selection in the Properties window
  • 11. Instrospection • builder tools typically provide a property sheet where one can conveniently set the properties of a JavaBean component. • In order to provide this service a builder tool needs to examine the component for its features (=properties, events and methods).This process is referred to as “introspection”. • Introspection is the automatic process of analyzing a bean's design patterns to reveal the bean's properties, events, and methods. This process controls the publishing and discovery of bean operations and properties.
  • 12. • To obtain information about a specific JavaBean one can use the static getBeanInfo() method of the Introspector class. • This method returns an instance of the BeanInfo class, which describes all features a JavaBean exposes. • use of this method is shown in the following code fragment: FontSelector fs = new FontSelector (); BeanInfo bi = Introspector . getBeanInfo (fs. getClass ());
  • 13. The following example represents code to perform introspection: • import java.beans.BeanInfo; • import java.beans.Introspector; • import java.beans.IntrospectionException; • import java.beans.PropertyDescriptor; • public class BeanDemo • { • private final String name = "BeanDemo"; • private int size; • public String getName() • { • return this.name; • } • public int getSize() • { • return this.size; • } • public void setSize( int size ) • { • this.size = size; • } • public static void main( String[] args ) • throws IntrospectionException • { • BeanInfo info = Introspector.getBeanInfo( BeanDemo.class ); • for ( PropertyDescriptor pd : info.getPropertyDescriptors() ) • System.out.println( pd.getName() ); • } • }
  • 14. • The above example creates a non-visual bean displays the following properties derived from the BeanInfo object. out put: class name size
  • 15. BeanInfo Interface • A bean implementor who wishes to provide explicit information about their bean may provide a BeanInfo class that implements this BeanInfo interface and provides explicit information about the methods, properties, events, etc, of their bean.
  • 16. Method Detail • getBeanDescriptor public BeanDescriptor getBeanDescriptor() Gets the beans BeanDescriptor. Returns:A BeanDescriptor providing overall information about the bean
  • 17. • getEventSetDescriptors public EventSetDescriptor[] getEventSetDescriptors() Gets the beans EventSetDescriptors. Returns:An array of EventSetDescriptors describing the kinds of events fired by this bean
  • 18. • getDefaultEventIndex • public int getDefaultEventIndex() • A bean may have a "default" event that is the event that will mostly commonly be used by humans when using the bean. Returns:Index of default event in the EventSetDescriptor array returned by getEventSetDescriptors.Returns -1 if there is no default event.
  • 19. • getPropertyDescriptors • public PropertyDescriptor[] getPropertyDescriptors() Gets the beans PropertyDescriptors. Returns:An array of PropertyDescriptors describing the editable properties supported by this bean.
  • 20. • getDefaultPropertyIndex • public int getDefaultPropertyIndex() • A bean may have a "default" property that is the property that will mostly commonly be initially chosen for update by human's who are customizing the bean. • Returns:Index of default property in the PropertyDescriptor array returned by getPropertyDescriptors.Returns -1 if there is no default property.
  • 21. • getMethodDescriptors • public MethodDescriptor[] getMethodDescriptors() • Gets the beans MethodDescriptors. • Returns:An array of MethodDescriptors describing the externally visible methods supported by this bean
  • 22. • getAdditionalBeanInfo public BeanInfo[] getAdditionalBeanInfo() that provide additional information on the current bean • getIcon public Image getIcon(int iconKind) This method returns an image object that can be used to represent the bean in toolboxes
  • 23. Properties • There exist four different kinds of properties a JavaBean can expose: 1. Simple 2. Indexed 3. Bound 4. Constrained • All types of property have in common that they are characterized by a pair of set/get methods.
  • 24. Simple Properties • As the name suggests, simple properties are the simplest of the four. • we would like to have a default font size, which will be used as initial font size at runtime.
  • 25. • Design patterns, where N is the name of the property and T is its type. public T getN( ); public void setN(T arg);
  • 26. The following listing shows a class that has three read/write simple properties: • public class Box { • private double depth, height, width; • public double getDepth( ) { • return depth; • } • public void setDepth(double d) { • depth = d; • } • public double getHeight( ) { • return height; • } • public void setHeight(double h) { • height = h; • } • public double getWidth( ) { • return width; • } • public void setWidth(double w) { • width = w; • } • }
  • 27. Indexed Properties • If a simple property can hold an array of value they are no longer called simple but instead indexed properties • An indexed property may expose set/get methods to read/write one element in the array and/or so-called ’array getter/setter’ which read/write the entire array.
  • 28. • design patterns, where N is the name of the property and T is its type: – public T getN(int index); – public void setN(int index, T value); – public T[ ] getN( ); – public void setN(T values[ ]);
  • 29. • The following listing shows a class that has one read/write indexed property: • public class PieChart { • private double data[ ]; • public double getData(int index) { • return data[index]; • } • public void setData(int index, double value) { • data[index] = value; • } • public double[ ] getData( ) { • return data; • } • public void setData(double[ ] values) { • data = new double[values.length]; • System.arraycopy(values, 0, data, 0, values.length); • } • }
  • 30. Bound Properties • A Bean that has a bound property generates an event when the property is changed. • Bound Properties are the properties of a JavaBean that inform its listeners about changes in its values. • Bound Properties are implemented using the PropertyChangeSupport class and its methods. • Bound Properties are always registered with an external event listener.
  • 31. • The event is of type PropertyChangeEvent and is sent to objects that previously registered an interest in receiving such notifications. • In order to provide this notification service a JavaBean needs to have the following two methods: public void addPropertyChangeListener(PropertyChangeListener p) { changes.addPropertyChangeListener(p); } public void removePropertyChangeListener(PropertyChangeListener p) { changes.removePropertyChangeListener(p); }
  • 32. Constrained Properties • A Bean that has a constrained property generates an event when an attempt is made to change its value. • Constrained Properties are implemented using the PropertyChangeEvent class. • The event is sent to objects that previously registered an interest in receiving such notifications. Those other objects have the ability to veto the proposed change. This capability allows a Bean to operate differently according to its run-time environment.
  • 33. • Constrained Properties are the properties that are protected from being changed by other JavaBeans. • Constrained Properties are registered with an external event listener that has the ability to either accept or reject the change in the value of a constrained property. • Constrained Properties can be retrieved using the get method. The prototype of the get method is: • Syntax: public string get<ConstrainedPropertyName>() • Can be specified using the set method. The prototype of the set method is: • Syntax: Public string set<ConstrainedPropertyName>(String str)throws PropertyVetoException
  • 34. Persistence • Persistence is the ability to save a Bean to nonvolatile storage and retrieve it at a later time. • Inorder to do this we take the help of BDK. Saving the beans in the BDK :choose “file” and then the “save” options. Restoring the beans in the BDK:choose “file” and then “load ” options.
  • 35. The Java Beans API • The Java Beans functionality is provided by a set of classes and interfaces in the java.beans package.
  • 36. Interface Description AppletInitializer Methods in this interface are used to initialize Beans that are also applets. BeanInfo This interface allows a designer to specify information about the properties, events, and methods of a Bean. Customizer This interface allows a designer to provide a graphical user interface through which a Bean may be configured. ExceptionListener A method in this interface is invoked when an exception has occurred PropertyChangeListener A method in this interface is invoked when a bound property is changed. PropertyEditor Objects that implement this interface allow designers to change and display property values
  • 37. Interface Description VetoableChangeListener A method in this interface is invoked when a constrained property is changed. Visibility Methods in this interface allow a Bean to execute in environments where a graphical user interface is not available.
  • 38. Class Description Encoder Encodes the state of a set of Beans. Can be used to write this information to a stream EventHandler Supports dynamic event listener creation EventSetDescriptor Instances of this class describe an event that can be generated by a Bean FeatureDescriptor This is the superclass of the PropertyDescriptor, EventSetDescriptor, and MethodDescriptor classes. IndexedPropertyDescriptor Instances of this class describe an indexed property of a Bean. SimpleBeanInfo This class provides functionality that can be used when writing BeanInfo classes
  • 39. Class description IntrospectionException An exception of this type is generated if a problem occurs when analyzing a Bean. Introspector This class analyzes a Bean and constructs a BeanInfo object that describes the component MethodDescriptor Instances of this class describe a method of a Bean. ParameterDescriptor Instances of this class describe a method parameter. PropertyChangeEvent This event is generated when bound or constrained properties are changed PropertyDescriptor Instances of this class describe a property of a Bean. PropertyEditorManager This class locates a PropertyEditor object for agiven type.