SlideShare a Scribd company logo
 An introduction to component-based
development in general
 Introduction to JavaBeans
 Java components
 client-side
 Working with the BDK
 The beans development life cycle
 Writing simple and advanced beans
 All engineering discplines use components to
build systems. In SE we rely on line-by-line SD.
 We have class libraries
 create objects from class libraries
 we still need to write a large amount of code
 objects are not enough
 They are like Integrated Circuit (IC)
components
 Over 20 years ago, hardware vendors learned
how to package transistors
 Hardware Engineers integrate ICs to make a
board of chips
 In SE, we are where hardware engineers were
20 years ago
 We are building software routines
 we can buy routines and use/reuse them in our
applications (assemble applications)
 JavaBeans -- portable, platform-independent
component model
 Java components are known as beans
 A bean: a reusable software component that
can be manipulated visually in a builder tool
 Beans are appropriate for software components
that can be visually manipulated
 Class libraries are good for providing
functionality that is useful to programmers,
and doesn’t benefit from visual manipulation
 A component is a self-contained reusable
software unit
 Components expose their features (public
methods and events) to builder tools
 A builder tool maintains Beans in a palette or
toolbox.
 You can select a bean from the toolbox, drop it
in a form, and modify its appearance and
behavior.
 Also, you can define its interaction with other
beans
 ALL this without a line of code.
 a public class with 0-argument constuctor
 it has properties with accessory methods
 it has events
 it can customized
 its state can be saved
 it can be analyzed by a builder tool
 A builder tool discover a bean’s features by a
process known as introspection.
 Adhering to specific rules (design pattern) when
naming Bean features.
 Providing property, method, and event information
with a related Bean Information class.
 Properties (bean’s appearance and behavior
characteristics) can be changed at design-time.
 Properties can be customized at design-time.
Customization can be done:
 using property editor
 using bean customizers
 Events are used when beans want to
intercommunicate
 Persistence: for saving and restoring the state
 Bean’s methods are regular Java methods.
 JavaBeans are subject to the standard Java
security model
 The security model has neither extended nor
relaxed.
 If a bean runs as an untrusted applet then it
will be subject to applet security
 If a bean runs as a stand-alone application then
it will be treated as a normal Java application.
 Assume your beans will be running in a multi-
threaded environment
 It is your responsibility (the developer) to make
sure that their beans behave properly under
multi-threaded access
 For simple beans, this can be handled by
simply making all methods …...
 To start the BeanBox:
 run.bat (Windows)
 run.sh (Unix)
 ToolBox contains the beans available
 BeanBox window is the form where you
visually wire beans together.
 Properties sheet: displays the properties for the
Bean currently selected within the BeanBox
window.
 Use screen captures from Windows
 Start application, following appears:
ToolBox has 16
sample
JavaBeans
BeanBox window
tests beans.
Properties
customizes
selected bean.
Method Tracer
displays debugging
messages (not
discussed)
 Initially, background selected
 Customize in Properties box
 Now, add JavaBean in BeanBox window
 Click ExplicitButton bean in ToolBox window
 Functions as a JButton
 Click crosshair where center of button should appear
 Change label to "Start the Animation"
 Select button (if not selected) and move to corner
 Position mouse on edges, move cursor appears
 Drag to new location
 Resize button
 Put mouse in corner, resize cursor
 Drag mouse to change size
 Add another button (same steps)
 "Stop the Animation"
 Add animation bean
 In ToolBox, select Juggler and add to BeanBox
 Animation begins immediately
Properties for
juggler.
 Now, "hook up" events from buttons
 Start and stop animation
 Edit menu
 Access to events from beans that are an event source
(bean can notify listener)
 Swing GUI components are beans
 Select "Stop the Animation"
 Edit->Events->button push -> actionPerformed
 Line appears from button to mouse
 Target selector - target of event
 Object with method we intend to call
 Connect the dots programming
 Click on Juggler, brings up EventTargetDialog
 Shows public methods
 Select stopJuggling
 Event hookup complete
 Writes new hookup/event adapter class
 Object of class registered as actionListener fro
button
 Can click button to stop animation
 Repeat for "Start the Animation" button
 Method startAnimation
 Save as design
 Can reloaded into BeanBox later
 Can have any file extension
 Opening
 Applet beans (like Juggler) begin executing
immediately
 import java.awt.*;
 import java.io.Serializable;
 public class FirstBean extends Canvas implements
Serializable {
 public FirstBean() {
 setSize(50,30);
 setBackground(Color.blue);
 }
 }
 Compile: javac FirstBean.java
 Create a manifest file:
 manifest.txt
 Name: FirstBean.class
 Java-Bean: True
 Create a jar file:
 jar cfm FirstBean.jar mani.txt FirstBean.class
import java.awt.*;
public class Spectrum extends Canvas {
private boolean vertical;
public Spectrum() {
vertical=true;
setSize (100,100);
}
public boolean getVertical() {
return (vertical);
}
public void setVertical(boolean vertical) {
this.vertical=vertical;
repaint ();
public void paint(Graphics g) {
float saturation=1.0f;
float brightness=1.0f;
Dimension d=getSize ();
if (vertical) {
for (int y=0;y<d.height;y++) {
float hue=(float) y/(d.height-1);
g.setColor(Color.getHSBColor(hue,saturation,brightness));
g.drawLine (0,y, d.width-1, y);
}
}
else {
for (int x=0;x<d.width; x++) {
float hue=(float) x/(d.height-1);
g.setColor(Color.getHSBColor(hue,
saturation,brightness));
g.drawLine (x, 0,x, d.width-1);
}
}
} // method ends
}// class ends
 The above Spectrum class is a subclass of
Canvas. The private boolean variable named
vertical is one of its properties. The constructor
initializes that property to true and sets the size
of the component.
 Bean’s appearance and behavior -- changeable
at design time.
 They are private values
 Can be accessed through getter and setter
methods
 getter and setter methods must follow some
rules -- design patterns (documenting
experience)
Copyright © 2001 Qusay H. Mahmoud
 A builder tool can:
 discover a bean’s properties
 determine the properties’ read/write attribute
 locate an appropriate “property editor” for each type
 display the properties (in a sheet)
 alter the properties at design-time
Copyright © 2001 Qusay H. Mahmoud
 Simple
 Index: multiple-value properties
 Bound: provide event notification when value
changes
 Constrained: how proposed changes can be
okayed or vetoed by other object
Copyright © 2001 Qusay H. Mahmoud
 When a builder tool introspect your bean it
discovers two methods:
 public Color getColor()
 public void setColor(Color c)
 The builder tool knows that a property named
“Color” exists -- of type Color.
 It tries to locate a property editor for that type
to display the properties in a sheet.
Copyright © 2001 Qusay H. Mahmoud
 Adding a Color property
 Create and initialize a private instance variable
 private Color color = Color.blue;
 Write public getter & setter methods
 public Color getColor() {
 return color;
 }
 public void setColor(Color c) {
 color = c;
 repaint();
 }
Copyright © 2001 Qusay H. Mahmoud
 For a bean to be the source of an event, it must
implement methods that add and remove
listener objects for the type of the event:
 public void add<EventListenerType>(<EventListenerType> elt);
 same thing for remove
 These methods help a source Bean know where
to fire events.
Copyright © 2001 Qusay H. Mahmoud
 Source Bean fires events at the listeners using
method of those interfaces.
 Example: if a source Bean register
ActionListsener objects, it will fire events at
those objects by calling the actionPerformed
method on those listeners
Copyright © 2001 Qusay H. Mahmoud
 Implementing the BeanInfo interface allows
you to explicitly publish the events a Bean fires
Copyright © 2001 Qusay H. Mahmoud
 Question: how does a Bean exposes its features
in a property sheet?
 Answer: using java.beans.Introspector class
(which uses Core Reflection API)
 The discovery process is named
“introspection”
 OR you can associate a class that implements
the BeanInfo with your bean
Copyright © 2001 Qusay H. Mahmoud
 Why use BeanInfo then?
 Using BeanInfo you can:
 Expose features that you want to expose
Copyright © 2001 Qusay H. Mahmoud
 The appearance and behavior of a bean can be
customized at design time.
 Two ways to customize a bean:
 using a property editor
 each bean property has its own editor
 a bean’s property is displayed in a property sheet
 using customizers
 gives you complete GUI control over bean
customization
 used when property editors are not practical
Copyright © 2001 Qusay H. Mahmoud
 A property editor is a user interface for editing
a bean property. The property must have both,
read/write accessor methods.
 A property editor must implement the
PropertyEditor interface.
 PropertyEditorSupport does that already, so you
can extend it.
Copyright © 2001 Qusay H. Mahmoud
 If you provide a custom property editor class,
then you must refer to this class by calling
PropertyDescriptor.setPropertyEditorClass in a
BeanInfo class.
 Each bean may have a BeanInfo class which
customizes how the bean is to appear.
SimpleBeanInfo implements that interface
Copyright © 2001 Qusay H. Mahmoud
 JavaBeans are just the start of the Software
Components industry.
 This market is growing in both, quantity and
quality.
 To promote commercial quality java beans
components and tools, we should strive to
make our beans as reusable as possible.
 Here are a few guidelines...
Copyright © 2001 Qusay H. Mahmoud
 Creating beans
 Your bean class must provide a zero-argument
constructor. So, objects can be created using
Bean.instantiate();
 The bean must support persistence
 implement Serializable or Externalizable
Copyright © 2001 Qusay H. Mahmoud

More Related Content

What's hot

Web controls
Web controlsWeb controls
Web controls
Sarthak Varshney
 
State Machine Diagram
State Machine DiagramState Machine Diagram
State Machine Diagram
Niloy Rocker
 
Android Intent.pptx
Android Intent.pptxAndroid Intent.pptx
Android Intent.pptx
vishal choudhary
 
Javabeans .pdf
Javabeans .pdfJavabeans .pdf
Javabeans .pdf
Rajkiran Mummadi
 
Asp.net file types
Asp.net file typesAsp.net file types
Asp.net file types
Siddhesh Palkar
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
BG Java EE Course
 
Unit iv
Unit ivUnit iv
Unit iv
bhushan_adavi
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformation
Selvakumar Gna
 
Spline representations
Spline representationsSpline representations
Spline representations
Nikhil krishnan
 
Asp objects
Asp objectsAsp objects
Asp objects
RajaRajeswari22
 
Servlet life cycle
Servlet life cycleServlet life cycle
Servlet life cycle
Venkateswara Rao N
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version Control
Jeremy Coates
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
Kamal Acharya
 
Ch 04 asp.net application
Ch 04 asp.net application Ch 04 asp.net application
Ch 04 asp.net application
Madhuri Kavade
 
Computer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2DComputer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2D
2013901097
 
Two dimensional geometric transformations
Two dimensional geometric transformationsTwo dimensional geometric transformations
Two dimensional geometric transformations
Mohammad Sadiq
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
Anuja Arosha
 
Decision statements in vb.net
Decision statements in vb.netDecision statements in vb.net
Decision statements in vb.net
ilakkiya
 
Sgml
SgmlSgml
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
Ankit Garg
 

What's hot (20)

Web controls
Web controlsWeb controls
Web controls
 
State Machine Diagram
State Machine DiagramState Machine Diagram
State Machine Diagram
 
Android Intent.pptx
Android Intent.pptxAndroid Intent.pptx
Android Intent.pptx
 
Javabeans .pdf
Javabeans .pdfJavabeans .pdf
Javabeans .pdf
 
Asp.net file types
Asp.net file typesAsp.net file types
Asp.net file types
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Unit iv
Unit ivUnit iv
Unit iv
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformation
 
Spline representations
Spline representationsSpline representations
Spline representations
 
Asp objects
Asp objectsAsp objects
Asp objects
 
Servlet life cycle
Servlet life cycleServlet life cycle
Servlet life cycle
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version Control
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 
Ch 04 asp.net application
Ch 04 asp.net application Ch 04 asp.net application
Ch 04 asp.net application
 
Computer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2DComputer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2D
 
Two dimensional geometric transformations
Two dimensional geometric transformationsTwo dimensional geometric transformations
Two dimensional geometric transformations
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Decision statements in vb.net
Decision statements in vb.netDecision statements in vb.net
Decision statements in vb.net
 
Sgml
SgmlSgml
Sgml
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
 

Viewers also liked

Javabeans
JavabeansJavabeans
Javabeans
vamsitricks
 
Introduction to java beans
Introduction to java beansIntroduction to java beans
Introduction to java beans
Hitesh Parmar
 
javabeans
javabeansjavabeans
javabeans
Arjun Shanka
 
Java Networking
Java NetworkingJava Networking
Java Networking
Ankit Desai
 
Beans presentation
Beans presentationBeans presentation
Beans presentation
manjusha ganesan
 
Java beans
Java beansJava beans
Java beans
Bipin Bedi
 
Santa Ana School.pptx
Santa Ana School.pptxSanta Ana School.pptx
Santa Ana School.pptx
sofiathoma
 
Bean Intro
Bean IntroBean Intro
Bean Intro
vikram singh
 
introduction of Java beans
introduction of Java beansintroduction of Java beans
introduction of Java beans
shravan kumar upadhayay
 
Reflection and Introspection
Reflection and IntrospectionReflection and Introspection
Reflection and Introspection
adil raja
 
Java Serialization
Java SerializationJava Serialization
Java Serialization
imypraz
 
Java beans
Java beansJava beans
Java beans
Ravi Kant Sahu
 
Java Reflection Explained Simply
Java Reflection Explained SimplyJava Reflection Explained Simply
Java Reflection Explained Simply
Ciaran McHale
 
Reflection in java
Reflection in javaReflection in java
Reflection in java
upen.rockin
 
.NET Vs J2EE
.NET Vs J2EE.NET Vs J2EE
.NET Vs J2EE
ravikirantummala2000
 
J2EE Introduction
J2EE IntroductionJ2EE Introduction
J2EE Introduction
Patroklos Papapetrou (Pat)
 

Viewers also liked (16)

Javabeans
JavabeansJavabeans
Javabeans
 
Introduction to java beans
Introduction to java beansIntroduction to java beans
Introduction to java beans
 
javabeans
javabeansjavabeans
javabeans
 
Java Networking
Java NetworkingJava Networking
Java Networking
 
Beans presentation
Beans presentationBeans presentation
Beans presentation
 
Java beans
Java beansJava beans
Java beans
 
Santa Ana School.pptx
Santa Ana School.pptxSanta Ana School.pptx
Santa Ana School.pptx
 
Bean Intro
Bean IntroBean Intro
Bean Intro
 
introduction of Java beans
introduction of Java beansintroduction of Java beans
introduction of Java beans
 
Reflection and Introspection
Reflection and IntrospectionReflection and Introspection
Reflection and Introspection
 
Java Serialization
Java SerializationJava Serialization
Java Serialization
 
Java beans
Java beansJava beans
Java beans
 
Java Reflection Explained Simply
Java Reflection Explained SimplyJava Reflection Explained Simply
Java Reflection Explained Simply
 
Reflection in java
Reflection in javaReflection in java
Reflection in java
 
.NET Vs J2EE
.NET Vs J2EE.NET Vs J2EE
.NET Vs J2EE
 
J2EE Introduction
J2EE IntroductionJ2EE Introduction
J2EE Introduction
 

Similar to Java beans

Java beans
Java beansJava beans
Java beans
Umair Liaqat
 
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 Unit 4(part 2)
Java Beans Unit 4(part 2)Java Beans Unit 4(part 2)
Java Beans Unit 4(part 2)
SURBHI SAROHA
 
Code camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyCode camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una Daly
Una Daly
 
Java beans
Java beansJava beans
Java beans
Vaibhav Shukla
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
Hussain Behestee
 
Class 1 blog
Class 1 blogClass 1 blog
Class 1 blog
Narcisa Velez
 
UIAutomator
UIAutomatorUIAutomator
UIAutomator
Sandip Ganguli
 
SoapUI Pro Plugin Workshop #SoapUIPlugins
SoapUI Pro Plugin Workshop #SoapUIPluginsSoapUI Pro Plugin Workshop #SoapUIPlugins
SoapUI Pro Plugin Workshop #SoapUIPlugins
SmartBear
 
CommercialSystemsBahman.ppt
CommercialSystemsBahman.pptCommercialSystemsBahman.ppt
CommercialSystemsBahman.ppt
KalsoomTahir2
 
Lecture 2 Styling and Layout in React Native.pptx
Lecture 2 Styling and Layout in React Native.pptxLecture 2 Styling and Layout in React Native.pptx
Lecture 2 Styling and Layout in React Native.pptx
GevitaChinnaiah
 
Javabean1
Javabean1Javabean1
Javabean1
Saransh Garg
 
Introducing PanelKit
Introducing PanelKitIntroducing PanelKit
Introducing PanelKit
Louis D'hauwe
 
Unit4wt
Unit4wtUnit4wt
Unit4wt
vamsi krishna
 
UNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdfUNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdf
PriyanshiPrajapati27
 
Model View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In AspnetModel View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In Aspnet
rainynovember12
 
Unit4wt
Unit4wtUnit4wt
Unit4wt
vamsitricks
 
Top Tips for Android UIs - Getting the Magic on Tablets
Top Tips for Android UIs - Getting the Magic on TabletsTop Tips for Android UIs - Getting the Magic on Tablets
Top Tips for Android UIs - Getting the Magic on Tablets
Motorola Mobility - MOTODEV
 
Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
Dhaval Kaneria
 
Volley lab btc_bbit
Volley lab btc_bbitVolley lab btc_bbit
Volley lab btc_bbit
CarWash1
 

Similar to Java beans (20)

Java beans
Java beansJava beans
Java beans
 
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
 
Java Beans Unit 4(part 2)
Java Beans Unit 4(part 2)Java Beans Unit 4(part 2)
Java Beans Unit 4(part 2)
 
Code camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyCode camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una Daly
 
Java beans
Java beansJava beans
Java beans
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
 
Class 1 blog
Class 1 blogClass 1 blog
Class 1 blog
 
UIAutomator
UIAutomatorUIAutomator
UIAutomator
 
SoapUI Pro Plugin Workshop #SoapUIPlugins
SoapUI Pro Plugin Workshop #SoapUIPluginsSoapUI Pro Plugin Workshop #SoapUIPlugins
SoapUI Pro Plugin Workshop #SoapUIPlugins
 
CommercialSystemsBahman.ppt
CommercialSystemsBahman.pptCommercialSystemsBahman.ppt
CommercialSystemsBahman.ppt
 
Lecture 2 Styling and Layout in React Native.pptx
Lecture 2 Styling and Layout in React Native.pptxLecture 2 Styling and Layout in React Native.pptx
Lecture 2 Styling and Layout in React Native.pptx
 
Javabean1
Javabean1Javabean1
Javabean1
 
Introducing PanelKit
Introducing PanelKitIntroducing PanelKit
Introducing PanelKit
 
Unit4wt
Unit4wtUnit4wt
Unit4wt
 
UNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdfUNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdf
 
Model View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In AspnetModel View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In Aspnet
 
Unit4wt
Unit4wtUnit4wt
Unit4wt
 
Top Tips for Android UIs - Getting the Magic on Tablets
Top Tips for Android UIs - Getting the Magic on TabletsTop Tips for Android UIs - Getting the Magic on Tablets
Top Tips for Android UIs - Getting the Magic on Tablets
 
Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
 
Volley lab btc_bbit
Volley lab btc_bbitVolley lab btc_bbit
Volley lab btc_bbit
 

More from Ramraj Choudhary

Pulse shaping
Pulse shapingPulse shaping
Pulse shaping
Ramraj Choudhary
 
Mobile computing
Mobile computingMobile computing
Mobile computing
Ramraj Choudhary
 
Cookies
CookiesCookies
Microprocessors
MicroprocessorsMicroprocessors
Microprocessors
Ramraj Choudhary
 
Joins
JoinsJoins
Joins
JoinsJoins
Grid computing
Grid computingGrid computing
Grid computing
Ramraj Choudhary
 
View
ViewView

More from Ramraj Choudhary (8)

Pulse shaping
Pulse shapingPulse shaping
Pulse shaping
 
Mobile computing
Mobile computingMobile computing
Mobile computing
 
Cookies
CookiesCookies
Cookies
 
Microprocessors
MicroprocessorsMicroprocessors
Microprocessors
 
Joins
JoinsJoins
Joins
 
Joins
JoinsJoins
Joins
 
Grid computing
Grid computingGrid computing
Grid computing
 
View
ViewView
View
 

Recently uploaded

What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
kalichargn70th171
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 

Recently uploaded (20)

What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 

Java beans

  • 1.  An introduction to component-based development in general  Introduction to JavaBeans  Java components  client-side  Working with the BDK  The beans development life cycle  Writing simple and advanced beans
  • 2.  All engineering discplines use components to build systems. In SE we rely on line-by-line SD.  We have class libraries  create objects from class libraries  we still need to write a large amount of code  objects are not enough
  • 3.  They are like Integrated Circuit (IC) components  Over 20 years ago, hardware vendors learned how to package transistors  Hardware Engineers integrate ICs to make a board of chips  In SE, we are where hardware engineers were 20 years ago  We are building software routines
  • 4.  we can buy routines and use/reuse them in our applications (assemble applications)  JavaBeans -- portable, platform-independent component model  Java components are known as beans  A bean: a reusable software component that can be manipulated visually in a builder tool
  • 5.  Beans are appropriate for software components that can be visually manipulated  Class libraries are good for providing functionality that is useful to programmers, and doesn’t benefit from visual manipulation
  • 6.  A component is a self-contained reusable software unit  Components expose their features (public methods and events) to builder tools  A builder tool maintains Beans in a palette or toolbox.
  • 7.  You can select a bean from the toolbox, drop it in a form, and modify its appearance and behavior.  Also, you can define its interaction with other beans  ALL this without a line of code.
  • 8.  a public class with 0-argument constuctor  it has properties with accessory methods  it has events  it can customized  its state can be saved  it can be analyzed by a builder tool
  • 9.  A builder tool discover a bean’s features by a process known as introspection.  Adhering to specific rules (design pattern) when naming Bean features.  Providing property, method, and event information with a related Bean Information class.  Properties (bean’s appearance and behavior characteristics) can be changed at design-time.
  • 10.  Properties can be customized at design-time. Customization can be done:  using property editor  using bean customizers  Events are used when beans want to intercommunicate  Persistence: for saving and restoring the state  Bean’s methods are regular Java methods.
  • 11.  JavaBeans are subject to the standard Java security model  The security model has neither extended nor relaxed.  If a bean runs as an untrusted applet then it will be subject to applet security  If a bean runs as a stand-alone application then it will be treated as a normal Java application.
  • 12.  Assume your beans will be running in a multi- threaded environment  It is your responsibility (the developer) to make sure that their beans behave properly under multi-threaded access  For simple beans, this can be handled by simply making all methods …...
  • 13.  To start the BeanBox:  run.bat (Windows)  run.sh (Unix)
  • 14.  ToolBox contains the beans available  BeanBox window is the form where you visually wire beans together.  Properties sheet: displays the properties for the Bean currently selected within the BeanBox window.
  • 15.  Use screen captures from Windows  Start application, following appears: ToolBox has 16 sample JavaBeans BeanBox window tests beans. Properties customizes selected bean. Method Tracer displays debugging messages (not discussed)
  • 16.  Initially, background selected  Customize in Properties box
  • 17.  Now, add JavaBean in BeanBox window  Click ExplicitButton bean in ToolBox window  Functions as a JButton  Click crosshair where center of button should appear  Change label to "Start the Animation"
  • 18.  Select button (if not selected) and move to corner  Position mouse on edges, move cursor appears  Drag to new location  Resize button  Put mouse in corner, resize cursor  Drag mouse to change size
  • 19.  Add another button (same steps)  "Stop the Animation"  Add animation bean  In ToolBox, select Juggler and add to BeanBox  Animation begins immediately Properties for juggler.
  • 20.  Now, "hook up" events from buttons  Start and stop animation  Edit menu  Access to events from beans that are an event source (bean can notify listener)  Swing GUI components are beans  Select "Stop the Animation"  Edit->Events->button push -> actionPerformed
  • 21.  Line appears from button to mouse  Target selector - target of event  Object with method we intend to call  Connect the dots programming  Click on Juggler, brings up EventTargetDialog  Shows public methods  Select stopJuggling
  • 22.  Event hookup complete  Writes new hookup/event adapter class  Object of class registered as actionListener fro button  Can click button to stop animation  Repeat for "Start the Animation" button  Method startAnimation
  • 23.  Save as design  Can reloaded into BeanBox later  Can have any file extension  Opening  Applet beans (like Juggler) begin executing immediately
  • 24.  import java.awt.*;  import java.io.Serializable;  public class FirstBean extends Canvas implements Serializable {  public FirstBean() {  setSize(50,30);  setBackground(Color.blue);  }  }
  • 25.  Compile: javac FirstBean.java  Create a manifest file:  manifest.txt  Name: FirstBean.class  Java-Bean: True  Create a jar file:  jar cfm FirstBean.jar mani.txt FirstBean.class
  • 26. import java.awt.*; public class Spectrum extends Canvas { private boolean vertical; public Spectrum() { vertical=true; setSize (100,100); } public boolean getVertical() { return (vertical); } public void setVertical(boolean vertical) { this.vertical=vertical; repaint ();
  • 27. public void paint(Graphics g) { float saturation=1.0f; float brightness=1.0f; Dimension d=getSize (); if (vertical) { for (int y=0;y<d.height;y++) { float hue=(float) y/(d.height-1); g.setColor(Color.getHSBColor(hue,saturation,brightness)); g.drawLine (0,y, d.width-1, y); }
  • 28. } else { for (int x=0;x<d.width; x++) { float hue=(float) x/(d.height-1); g.setColor(Color.getHSBColor(hue, saturation,brightness)); g.drawLine (x, 0,x, d.width-1); } } } // method ends }// class ends
  • 29.  The above Spectrum class is a subclass of Canvas. The private boolean variable named vertical is one of its properties. The constructor initializes that property to true and sets the size of the component.
  • 30.
  • 31.  Bean’s appearance and behavior -- changeable at design time.  They are private values  Can be accessed through getter and setter methods  getter and setter methods must follow some rules -- design patterns (documenting experience) Copyright © 2001 Qusay H. Mahmoud
  • 32.  A builder tool can:  discover a bean’s properties  determine the properties’ read/write attribute  locate an appropriate “property editor” for each type  display the properties (in a sheet)  alter the properties at design-time Copyright © 2001 Qusay H. Mahmoud
  • 33.  Simple  Index: multiple-value properties  Bound: provide event notification when value changes  Constrained: how proposed changes can be okayed or vetoed by other object Copyright © 2001 Qusay H. Mahmoud
  • 34.  When a builder tool introspect your bean it discovers two methods:  public Color getColor()  public void setColor(Color c)  The builder tool knows that a property named “Color” exists -- of type Color.  It tries to locate a property editor for that type to display the properties in a sheet. Copyright © 2001 Qusay H. Mahmoud
  • 35.  Adding a Color property  Create and initialize a private instance variable  private Color color = Color.blue;  Write public getter & setter methods  public Color getColor() {  return color;  }  public void setColor(Color c) {  color = c;  repaint();  } Copyright © 2001 Qusay H. Mahmoud
  • 36.  For a bean to be the source of an event, it must implement methods that add and remove listener objects for the type of the event:  public void add<EventListenerType>(<EventListenerType> elt);  same thing for remove  These methods help a source Bean know where to fire events. Copyright © 2001 Qusay H. Mahmoud
  • 37.  Source Bean fires events at the listeners using method of those interfaces.  Example: if a source Bean register ActionListsener objects, it will fire events at those objects by calling the actionPerformed method on those listeners Copyright © 2001 Qusay H. Mahmoud
  • 38.  Implementing the BeanInfo interface allows you to explicitly publish the events a Bean fires Copyright © 2001 Qusay H. Mahmoud
  • 39.  Question: how does a Bean exposes its features in a property sheet?  Answer: using java.beans.Introspector class (which uses Core Reflection API)  The discovery process is named “introspection”  OR you can associate a class that implements the BeanInfo with your bean Copyright © 2001 Qusay H. Mahmoud
  • 40.  Why use BeanInfo then?  Using BeanInfo you can:  Expose features that you want to expose Copyright © 2001 Qusay H. Mahmoud
  • 41.  The appearance and behavior of a bean can be customized at design time.  Two ways to customize a bean:  using a property editor  each bean property has its own editor  a bean’s property is displayed in a property sheet  using customizers  gives you complete GUI control over bean customization  used when property editors are not practical Copyright © 2001 Qusay H. Mahmoud
  • 42.  A property editor is a user interface for editing a bean property. The property must have both, read/write accessor methods.  A property editor must implement the PropertyEditor interface.  PropertyEditorSupport does that already, so you can extend it. Copyright © 2001 Qusay H. Mahmoud
  • 43.  If you provide a custom property editor class, then you must refer to this class by calling PropertyDescriptor.setPropertyEditorClass in a BeanInfo class.  Each bean may have a BeanInfo class which customizes how the bean is to appear. SimpleBeanInfo implements that interface Copyright © 2001 Qusay H. Mahmoud
  • 44.  JavaBeans are just the start of the Software Components industry.  This market is growing in both, quantity and quality.  To promote commercial quality java beans components and tools, we should strive to make our beans as reusable as possible.  Here are a few guidelines... Copyright © 2001 Qusay H. Mahmoud
  • 45.  Creating beans  Your bean class must provide a zero-argument constructor. So, objects can be created using Bean.instantiate();  The bean must support persistence  implement Serializable or Externalizable Copyright © 2001 Qusay H. Mahmoud