BEAN, JAR (file format)
Mr. Anil kr Pandey
JavaBeans
A JavaBean is a specially constructed Java class written in the
Java and coded according to the JavaBeans API specifications.
Following are the unique characteristics that distinguish a
JavaBean from other Java classes −
• It provides a default, no-argument constructor.
• It should be serializable and that which can implement
the Serializable interface.
• It may have a number of properties which can be read or written.
• It may have a number of "getter" and "setter" methods for the
properties.
• A JavaBean property is a named attribute that can be
accessed by the user of the object. The attribute can be
of any Java data type, including the classes that you
define.
• A JavaBean property may be read, write, read only,
or write only. JavaBean properties are accessed through
two methods in the JavaBean's implementation class −
• The following table describes the Enterprise Beans that you can
execute in the EJB container provided with Application Server:
Application Builder Tools
When working with Java Beans, most developers use an application builder tool, a
utility that enables. you to configure a set of Beans, connect them together, and produce
a working application. Its major capabilities arc the following:
• 1. A palette is provided that lists all of the available Beans. As addition Beans are
developed or purchased, they can be added to the palette.
• 2.A worksheet is displayed that allows the designer to lay but Beans in a graphical user
interface. A designer may drag and drop a Bean from the palette to this worksheet.
• [Link] editors and customize allow a Bean to be configured. This is the mechanism
by which the behavior of a Bean may be a particular environment.
• [Link] allow a designer to inquire about the slate ‘and behavior of a Bean. This
informational automatically becomes available when a Bean is added to the palate
• 5. Capabilities exist to interconnect Beans. This means that events generated by one’
component are mapped to method invocations on other components.
• 7. When a collection of Beans has been configured and connected, it is possible. to save
all of this information in a persistent storage area. At a later time, this information can
then be used to restore the state of the application .
Software
Components
• 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
JavaBeans vs. Class
Libraries
• 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
JavaBeans Concepts
• 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.
Concepts...
• 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 [Link] this without a line of code.
JavaBean
Characteristics
• 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
Key Concepts
• 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.
Security Issues
• 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.
BDK
• 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.
• JavaSoft's Beans Development Kit provides a simple
application named the BeanBox tool for testing your
beans and simple applications composed of beans. The
BeanBox tool is itself a composite JavaBean application.
• The BeanBox tool displays a form (the BeanBox window)
where you place and arrange beans. You then connect
the beans together so that they can communicate. The
resulting application can be saved and reloaded through
the BeanBox tool.
Bean Customization
• 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
Introspection
• Introspection in java is used in the context of Java
beans which defines the component model of java.
• Introspection feature enables a java bean to get the
properties, methods and events of other beans at runtime.
This helps the developers to design and develop
their beans without knowing the details of other beans.
How to be a good
bean?
• 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.
JAR (file format)
• A JAR (Java ARchive) is a package file format typically used to
aggregate many Java class files and associated metadata and
resources (text, images, etc.) into one file for distribution.[3]
• A JAR file allows Java runtimes to efficiently deploy an entire
application, including its classes and their associated resources,
in a single request. JAR file elements may be compressed,
shortening download times.
• A JAR file may contain a manifest file, that is located at META-
INF/[Link]. The entries in the manifest file describe
how to use the JAR file. For instance, a Classpath entry can be
used to specify other JAR files to load with the JAR.