Unit 5
Unit 5
JavaBeans are classes which encapsulate several objects into a single object. It
helps in accessing these object from multiple places. JavaBeans contains
several elements like Constructors, Getter/Setter Methods and much more.
1: Getters
2: Setters
1. getEmployeeName ()
For example, if the employee name is firstName, the method name would be
getFirstName() to read that employee name. This method is known as an
accessor. Properties of getter methods are as follows:
2.setEmployeeName ()
For example, if the employee name is firstName, the method name would be
setFirstName() to write that employee name. This method is known as a
mutator. Properties of setter methods:
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.
3.Special 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.
4.Commands 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 Prepared by : Dr. Ahmad Jamal
5. Capabilities exist to interconnect Beans. This means that events generated
by one’ component are mapped to method invocations on other components.
The Bean Developer Kit (BDK), available from the Java Soft site, is a simple
example of a tool that enables you to create, configure, and connect a set of
Beans. There is also a set of sample Beans with their source code.
NOTE: BDK is no longer available for download from the Java website.
Here, cf represents to create the file, tf represents the table view of file contents.
Prepared by : Dr. Ahmad Jamal
Syntax(Extracting a JAR file)
jar xf jarfilename
Here, xf represents extract files from the jar files, ‘uf’ represents the updated jar
file.
The following are characteristics differentiating entity beans from session beans:
Entity beans are retained after the end of a session, unlike session beans.
Entity beans permit shared data access.
Entity beans have a primary key or a unique identifier.
Prepared by : Dr. Ahmad Jamal
Enterprise Java Beans
Enterprise Java Beans (EJB) is one of the several Java APIs for standard
manufacture of enterprise software. EJB is a server-side software element that
summarizes business logic of an application.
2. The beans rather than the clients contain the application’s business logic, the
client developer can focus on the presentation of the client. The client developer
does not have to code the pattern that execute business rules or access
databases. Due to this the clients are thinner which is a benefit that is
particularly important for clients that run on small devices.
3. Enterprise Java Beans are portable elements, the application assembler can
build new applications from the beans that already exists.
The RMI provides remote communication between the applications using two
objects stub and skeleton.
A remote object is an object whose method can be invoked from another JVM.
It initiates a connection with remote Virtual Machine (JVM),
It writes and transmits the parameters to the remote Virtual Machine (JVM),
It waits for the result
It reads the return value or exception, and
It finally, returns the value to the caller.
It reads the parameter for the remote
method
It invokes the method on the actual
remote object, and
It writes and transmits (marshals) the
result to the caller.