Sie sind auf Seite 1von 11

Assignment No.

: Date :
Assignment Name : Study and submit any of MVC (Model View Control) based framework
(J2EE / EJB).
Batch :
Roll No. :
------------------------------------------------------------------------------------------------------------------------
Modelviewcontroller

Modelviewcontroller (MVC) is a software architectural pattern for implementing user interfaces.
It divides a given software application into three interconnected parts, so as to separate internal
representations of information from the ways that information is presented to or accepted from the
user.As with other software patterns, MVC expresses the "core of the solution" to a problem while
allowing it to be adapted for each system. Particular MVC architectures can vary significantly from
the traditional description here.

Components

The central component of MVC, the model, captures the application's behavior in terms of its
problem domain, independent of the user interface. The model directly manages the application's
data, logic and rules. A view can be any output representation of information, such as a chart or a
diagram; multiple views of the same information are possible, such as a bar chart for management
and a tabular view for accountants. The third part, the controller, accepts input and converts it to
commands for the model or view.

A controller can send commands to the model to update the model's state (e.g., editing a
document). It can also send commands to its associated view to change the view's presentation of
the model (e.g., by scrolling through a document).The controller translates the users interactions
with the view into actions that the model will perform. In a stand-alone GUI client, user interactions
could be button clicks or menu selections, whereas in an enterprise web application, they appear as
GET and POST HTTP requests. Depending on the context, a controller may also select a new view
for example, a web page of results to present back to the user.

A model notifies its associated views and controllers when there has been a change in its state.
This notification allows the views to produce updated output, and the controllers to change the
available set of commands. In some cases an MVC implementation might instead be "passive,"



so that other components must poll the model for updates rather than being notified.The model
represents data and the rules that govern access to and updates of this data. In enterprise
software, a model often serves as a software approximation of a real-world process.

A view requests information from the model that it uses to generate an output representation to
the user. The view renders the contents of a model. It specifies exactly how the model data
should be presented. If the model data changes, the view must update its presentation as needed.
This can be achieved by using a push model, in which the view registers itself with the model
for change notifications, or a pull model, in which the view is responsible for calling the model
when it needs to retrieve the most current data.

Interactions

In addition to dividing the application into three kinds of components, the modelview controller
design defines the interactions between them.












Architecture





Interaction Between MVC Components

This section will take a closer look at one way to implement in above figure the context of an
application in the Java Platform, Standard Edition 6 (Java SE 6). Once the model, view, and
controller objects are instantiated, the following occurs:
The view registers as a listener on the model. Any changes to the underlying data of the model
immediately result in a broadcast change notification, which the view receives. This is an
example of the push model described earlier. Note that the model is not aware of the view or the
controller it simply broadcasts change notifications to all interested listeners.
The controller is bound to the view. This typically means that any user actions that are
performed on the view will invoke a registered listener method in the controller class.
The controller is given a reference to the underlying model.

Once a user interacts with the view, the following actions occur :




The view recognizes that a GUI action. for example, pushing a button or dragging a scroll bar
has occurred, using a listener method that is registered to be called when such an action occurs.
The view calls the appropriate method on the controller.
The controller accesses the model, possibly updating it in a way appropriate to the users action.
If the model has been altered, it notifies interested listeners, such as the view, of the change.
In some architectures, the controller may also be responsible for updating the view. This is
common in Java technology-based enterprise applications.
































Enterprise JavaBeans (EJB) framework

Enterprise JavaBeans (EJB) is a component-based architecture for developing, deploying, and
managing reliable enterprise applications in production environments. EJB architecture is at the
heart of the Java 2 platform, Enterprise Edition (J2EE). With the growth of the Web and the
Internet, more and more enterprise applications are now Web based, including both intranet and
extranet applications. Together, the J2EE and EJB architectures provide superior support for
Webbased enterprise applications.

The following is a summary of todays target in exploring both the EJB technology and J2EE
architecture.

What EJB is, and its benefits in simplifying the writing of enterprise applications. How EJB
is different from ordinary JavaBeans. About the big picture of the J2EE, and where EJB fits into it.
What flavours of beans are available, and the characteristics of each, If the model has been altered,
it notifies interested listeners, such as the view, of the change. In some architectures, the controller
may also be responsible for updating the view. This is common in Java technology-based enterprise
applications. The importance of the EJB container, and the available common services provided to
your beans. More about the roles and responsibilities in developing and deploying J2EE
applications who does what

The Challenges of Developing Enterprise Applications :

Enterprise applications are facing many challenges, such as portability, reusability,
interoperability, and application integration. Since the inception of Java in 1995 as a simple
objectoriented and portable language, its main focus was on the development of portable client-side
applications. The challenges of developing portable Java enterprise applications remain due to the
lack of server-side application development framework and tools. By server-side computing, we
imply the design of small, location-transparent components that work together to fulfill enterprise
service requirements. In many cases, these lightweight components can work as both client and
server.
Enterprise computing is rapidly changing in both hardware and software. New applications are
required to meet with the emerging user demands, and are still required to interface with existing
applications. Its not practical to throw out the huge investment in applications written in older-



generation languages that already work to maintain data in legacy systems. This dictates a need to
integrate new applications with the existing systems. Today, server-side software offers the
corporate world many opportunities to rethink its enterprise-wide computing infrastructure. With
the acceptance and growth of Java in recent years, software portability, reuse, and application
integration have become important and accepted for many client applications spread throughout the
enterprise.
Enterprise applications are complex, and in many cases require the development of several teams,
which might span multiple domains. Todays applications are required to have faster time to market
to compete and to fulfill user demands. Another challenge facing the enterprise is interoperability
with other environments, which might be heterogeneous in hardware, software, or network
architectures.
In facing such challenges, enterprise application architectures have undergone an extensive
evolution. The first generation of enterprise applications was centralized mainframe applications. In
the late 1980s and early 1990s, most new enterprise applications followed a two-tier architecture
approach (also known as the client/server architecture). Later, the enterprise architecture evolved to
a three-tier, and then to a Web-based architecture.
One of the solutions for these challenges is the J2EE technology, which was developed by Sun
Microsystems. The following sections describe the J2EE architecture and, as a major participant,
the EJB technology of developing component-based enterprise applications.

Whats an EJB ?

Lets first understand the meaning of component and server component model, and then examine
the meaning of EJB. A component is a piece of code that implements well-defined interfaces.
Typically, it lives in a runtime environment and takes advantage of the services offered by the
environment. For the component to live in a runtime environment, it must follow the rules of the
runtime environment. This ensures the proper functioning of the runtime environment and the
portability and scalability of the component. A component is not a complete application. An
application consists of multiple components working together.
Generally, developing server-side objects is more difficult than writing graphical user interface
(GUI) or client components. This is because in addition to writing business application logic, the
developers must also take care of system-level issues such as multithreading, access to databases,
efficient management of resources, transactions, security, access to legacy systems, and so on. A
server component model or architecture provides support for server-side components. This



simplifies the development of server-side components and allows developers to focus on developing
business application logic.
An enterprise bean is a server-side component that implements the business logic of an enterprise
application and adheres to the rules of the Enterprise JavaBean architecture. Enterprise beans live in
an EJB containera runtime environment within a J2EE server. The EJB container provides
multiple services to support the enterprise beans.

The following are the characteristics of EJBs :

Support visual software development tools : The class must expose variables (called
properties), methods, and events.

Customizable : This includes support for default property editors or provision for unique
custom routines. Customization permits developers to change the behaviour of a bean without
changing the source code.

Support introspection : This refers to disclosing properties, methods, and events to other
classes.

Persistent : This permits a bean to be saved in its customized state.

They contain business logic that operates on the enterprises data. They depend on a
container environment to supply life-cycle services for them. EJB instances are created and
maintained by the container. They can be customized at deployment time by editing the deployment
descriptor. System-level services, such as transaction management and security, are described
separately from the enterprise bean. A client never accesses an enterprise bean directly; the
container environment mediates access for the client. This provides component-location
transparency. The EJB is designed to be portable across EJB servers provided by different vendors.
They can be included in an assembled application without requiring source code changes or
recompilation of them. JavaBeans are not part of the J2EE architecture. Theyre being used for a
while as a data bean to transfer data from EJB components to Web components. JavaBeans are also
used in a few J2EE design patterns. The only similarity between an EJB and a JavaBean is that both
are components. An EJB does not have the same structure as a JavaBean. An EJB consists of two
interfaces and two classes, whereas a JavaBean consists of only one Java class. A JavaBean is local



to a single process and cant be shared by multiple users, while some types of EJB are shareable.
Beans are always single threaded; you never have to write thread-safe code.


Types of EJB :



Session beans, which are divided into stateless session beans and stateful session beans.

Entity beans, which are divided into bean-managed persistence and container-managed persistence.

Message-driven beans Later in this, youll be provided with a more detailed explanation of each
bean type. But for now, as a general rule, a session bean represents a user session (stateful or
stateless), and implements the workflow of an arbitrary business process. An entity bean, on the
other hand, represents a data row (record), in a database that can be accessed to satisfy user
requests. Although both session and entity beans are synchronous in nature, message-driven beans
are used to receive asynchronous messages, and process them accordingly.

EJB Architecture Overview :

The J2EE architecture is a consolidation of standards, specifications, frameworks, and guidelines to
provide Java capability on the server side for the enterprise. These standards and frameworks
consist of classes and interfaces to be implemented by both service providers and developers. The



EJB API is at the heart of the J2EE architecture. The other APIs are used as services to the EJB
API. Many middleware vendors have been delivering implementations of the server-side APIs for
the last few years.
A J2EE implementation can be obtained from many vendors today. The implementation of
the J2EE specification is realized through a Java application server, a product that offers the
infrastructure-base solutions to the enterprise needs. The most common application servers today
are BEAs WebLogic Server, IBMs WebSphere, and the open source JBoss.

Java on the client and on the server :




Application clients. These are standalone client-side Java applications, which are hosted on
client machines, and can use any relevant J2EE server-side functionality.

Applets. These are tiny client-side components hosted by a Web browser, and are mainly
convenient to use in initiating services and then displaying the results to the user.

Servlets and JavaServer Pages (JSP). Servlets are server-side Java components that process
requests on behalf of the users. Servlets invoke arbitrary services and process the results through
the generation of HTML output to be displayed on a Web browser. JSP is a convenient API for
embedding Java within HTML pages, from which the JSP implementation generates servlets.




Enterprise JavaBeans. EJBs are server-side components for encapsulating an applications
business logic. An EJB can offer specific enterprise service either alone or in conjunction with
other EJBs. EJBs can be packaged together to be available to deliver transactional and secure
enterprise applications over the network to other J2EE applications or services.


These components span multiple tiers, and a full coverage of multitier architecture and the
J2EE architecture will be discussed on Day 15, Understanding J2EE Architecture. Its worth
noting here that the introduction of browser-based clients, such as applets and form-based JSPs, has
contributed to accessing application functionality thats hosted on a remote server through a unified
form-based interaction. This shift from providing core corporate functionality at the PC and
workstation level to the server via remote access has intensified the focus on server-side software.

EJB Design Goals :

Since its inception by Sun Microsystems in 1997, the EJB architecture has had the following goals:

To be the standard component-based architecture for building distributed object-oriented
business applications in the Java programming language.

To make it easy to write enterprise applications. Developers will not have to understand
lowlevel transaction and state management details, multi-threading, connection pooling, and
other complex low-level APIs.

To enable an EJB to be developed once, and then deployed on multiple platforms without
recompilation or source code modification.

To address the development, deployment, and runtime aspects of an enterprise applications life
cycle. Also, to define those contracts that enable tools from multiple vendors to develop and
deploy components that can interoperate at runtime.

To be compatible with existing server platforms and with other Java programming language
APIs.




To provide interoperability between EJBs and J2EE components as well as non-Java
programming language applications.

To be compatible with the CORBA protocols.

EJB Server :

The EJB server (also known as the J2EE application server) is the outermost container of the
various elements that make up an EJB environment. The EJB server manages one or more EJB
containers and provides required support services, such as transaction management, persistence, and
client access. A JNDI-accessible naming space can be used by clients to locate the EJB. Figure 1.4
illustrates a J2EE application server. The J2EE application server also provides operation resources,
such as process and execution threads, memory, networking facilities, system resource
management, connection pooling and caching, load balancing, fail-over, and so on to the containers
and the elements within them. The EJB server can offer further vendor-specific features, such as
optimized database access drivers, interfaces to backend systems, and CORBA accessibility.

References :
www.comptechdoc.org/docs/kanti/ejb/ejbarchitecture.htmles
http://ejbvn.wordpress.com/category/week-1-enterprise-java-architecture
http://docs.oracle.com/cd/F49540_01/DOC/java.815/a64683/ejb4.htm
www.comptechdoc.org/docs/kanti/ejb/ejbarchitecture.htmls

Conclusion :
Thus we have studied MVC (Model View Control) based framework Enterprise
JavaBeans (EJB).

Das könnte Ihnen auch gefallen