Transcript beans
Introduction to Software
Components: the JavaBeans
specs
Babak Esfandiari
Software Components
Component: "Encapsulated software object
that provides a certain functionality or service
and can be used in conjunction with other
components to build applications."
one should be able to develop applications by
selecting components from a catalog and
compose them.
the catalogs and the components might reside
on remote hosts
Software Components
To be reusable, components:
–
–
–
–
expose a public interface
behave according to explicit specifications
are oblivious to their clients
can be assembled graphically
JavaBeans
Java's component model
JavaBeans Concepts
“ A Java Bean is a reusable software component that can be
manipulated visually in a builder tool”
-> JDK1.1
introspection
customization
events
properties
persistence
Introspection
JavaBeans assembly tools such as the
BeanBox are able to discover Bean properties
and expose them using introspection
–
–
the Java Reflection API is used
Beans must follow a certain number of coding
idioms
default constructor
public methods
getters/setters
events
Customization
once Bean properties are discovered, they can
be changed using introspection
it is possible to change the way properties are
accessed and modified
Events
JavaBeans use the Java Event model
–
–
EventObject class
EventListeners
Persistence
Instantiated JavaBeans' states can be saved
and restored using serialization
long-term persistence achieved with XML