java components
DESCRIPTION
JAVA Components. Seminar of “Component Based Software Engineering” course By : Z.Varamini U niversity of S cience and T echnology of M azandaran, B abol January 7,2010. Outline. Introduction to Java From Java to Java 2 Java 2 platforms Java Components - PowerPoint PPT PresentationTRANSCRIPT
JAVA Components
Seminar of “Component Based Software Engineering” course
By : Z.VaraminiUniversity of Science and Technology of Mazandaran,Babol
January 7,2010
Outline
Introduction to Java From Java to Java 2 Java 2 platforms Java Components
Applet,JavaBeans,Enterprise JavaBeans
JAVA Components2/22
JAVA
Released in alpha-form in 1995 by Sun Originality:Concepts of Applets Java become common used by 1996
JAVA Components3/22
Java 2
JAVA Components4/22
Introduced in late 1998 Relegates applets to a marginal side role Introduced the notion of platform editions
Java 2 Platforms
J2SE:Java 2 Platform , Standard Edition Use for Standard Programming
J2EE:Java 2 Platform ,Enterprise Edition Released end 1999 The Flagship platform edition The most Successful Programming for Enterprise Systems
J2ME:Java 2 Platform , Micro Edition Use for small and embeded device It was Successful in the mobile phone sector
JAVA Components5/22
Java-Components
Java component model :o Appleto JavaBeanso Enterprise JavaBeanso Servletso Application client components
JAVA Components6/22
J2SE
J2EE
Applet-Policy
Applet ,Is a software component that runs in the context of another program, for example a web browser
With Goal of adding Animation to Web Pages
Sun's Hot Java browser,the first browser that supports Applet
Netscape and Microsoft Internet Explorer,Then supports Applet when included a Java virtual machine
JAVA Components
7/22
Problems In Netscape and IE
They didn't keep up with more modern versions of Javao To overcome this problem, Sun released a tool called the
"Java Plug-in" o it seamlessly plugs in to both Netscape and Internet
Explorer and allows both browsers to execute Java applets by using an external Java runtime environment that Sun supplies
JAVA Components
8/22
Life Cycle of an Applet Four Method Controls An Applet
JAVA Components
9/22
Init()
Start()
Stop()
destroy()
Browser,Load its page
user moves off the page
User returns to the page
Browser shuts down normally
JavaBeans- What is ? JavaBeans are reusable software components
for Java that can be manipulated visually in a builder tool.
Practically, they are classes written in the Java programming language conforming to a particular convention.
They are used to encapsulate many objects into a single object (the bean)
A JavaBean is a Java Object that is serializable, has a nullaryconstructor, and allows access to properties using getter and setter methods.
10/22JAVA Components
JavaBeans- Solution to .. Enables Software developers to design
and create reusable pieces of software that easily integrateo with each other o with applications o with development tools
11/22JAVA Components
JavaBeans – Main aspects
Events Properties Introspection Customization Persistence
JAVA Components12/22
Enterprise JavaBeanse (EJB)
Provide a framework for component that may be “plugged in” to a server
Enterprise JavaBeans is totally different of JavaBeans,Except that it uses some similar concepts
JAVA Components13/22
EJB Vs JavaBean
Components built in the JavaBeansspecification are intraprocess components that stays in one address space and are typically used for Graphical User Interface (GUI) as visual widgets like buttons, tables, HTML viewers, etc
Components built in the EJB specification are interprocess components that stays in multipleaddress spaces as distributed object.
EJBs are not GUI components rather they sit behind the GUI's and perform all the hardcore business logic. GUIs like thick Clients, web-based Clients and web services are some of the Clients that can make connection to EJBs JAVA Components
14/22
Enterprise JavaBeanse-Goals
Easy for developers to creat applications
Standard way for client/server applications
Compatible with and uses other java APIS
EJB can interoperate with non-java apps
EJB is Compatible with CORBA
JAVA Components 15/22
What constitutes an EJB? EJB Object
Client never invokes the method on an actual bean instance. All invocations go through the EJB Object
Remote Interface This interface duplicates all the methods that
the corresponding bean class exposes
JAVA Components 16/22
What constitutes an EJB?(cont.)
Home Object How do clients acquire references to EJB objects?
The client asks for the EJB object fron the EJB Object factory
Home Interface How does a Home object know how you would like to intialize your EJB object?
This info is provided to the containerthrough Home interface
JAVA Components 17/22
What constitutes an EJB?(cont.)
Local Interfaces Creating the beans through the home interface and then calling the beans though the remote interface is very slow.Local Interfaces makes beans' call faster
Deployment Descriptor You state your middleware needs in the deployment descriptor. This file is an XML based file
EJB-jar files EJB-JAR files are essentially zip files that contain Java classes and other files needed for deployment. You can generate these files by hand or with tools, such as Apache Ant.
JAVA Components 18/22
What Specify in Deployment Descriptor ?
• Bean management and lifecycle requirements• Transaction requirements• Security requirements, including access
control entries
JAVA Components 19/22
Enterprise JavaBeans Component
JAVA Components20/22
EJB Server
EJB Container
EJB Home
EJB Object
EJB Bean
EJB Homestub
EJB Object stub
Home
Remot or Local
Home
Remot or Local
Client
Disadvantages of EJB They have a large and complicated Specification
EJBs take longer to develop, and when things go wrong, they can be more difficult to debug, because there can be a possibility that the bug may not be in your code but in the application server/container itself.
No sooner have you deployed your EJB application, you see a new specification with newer features, rendering your application obsolete before it gets online. This situation, however, is unavoidable.
JAVA Components 21/22
Reference
Clemens Szyperski, Dominik Gruntz and Stephan Murer, "Component Software - Beyond Object-Oriented Programming",Second Edition, Addison-Wesley/ACM Press, 2002 (589 pages), ISBN 0-201-74572-0en.wikipedia
Cay S. Horstmann, Gary Cornell,” Core Java™ 2 Volume I - Fundamentals”, Seventh Edition, Prentice Hall PTR, August 17 ,2004(784 pages) ISBN 0-13-148202-5
JAVA Components22/22