Presentation is loading. Please wait.

Presentation is loading. Please wait.

A Practical Introduction to Enterprise Java Beans

Similar presentations


Presentation on theme: "A Practical Introduction to Enterprise Java Beans"— Presentation transcript:

1 A Practical Introduction to Enterprise Java Beans
A Component Technology IN 30 MIN’s DO YOU WANT TO ANSWER MOST OF THE EJB QUESTIONS ? THEN LET ME HELP YOU! EJB The Heart of J2EE BY Kantimahanti Prasad or Copyright 2004 Kanti Prasad All rights reserved

2 Copyright 2004 Kanti Prasad All rights reserved
1. Learning objectives Component Technology characteristics Standard Infrastructure needs Application Servers Containers J2EE Architecture and its components EJB Model, Overview & JNDI EJB Specifications, Roles EJB Design Approaches, Architecture Types of Beans EJB Interfaces & Session Contexts Life cycles of different Beans EJB Jar files & Deployment Descriptor Sample examples Components comparison A STAR or a different color represents important points to NOTE Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

3 Copyright 2004 Kanti Prasad All rights reserved
2. About the Author Kantimahanti.N.S.Prasad Worked in fortune 100 Corporates in Client Server Technologies. Specializes in Architecture, Designing, Development & Managing day-to-day activities. Presently doing a PhD at Queens Uty, U.K in Adaptable Software specific to Component Technologies and has a M.B.A (Computer Applications) from an U.S. Uty. Business domain strengths are in Investment banking & Insurance. Process improvement strengths are in 6 - Sigma and CMM. His present & past working experiences in various global locations are in corporates like Pramerica (Prudential U.S), J P Morgan Chase, A B N Amro Bank & SGS. He was a part time visiting faculty in affiliates of Sydney University, Australia and All India Management Institute teaching I.T, Project Management & Statistics. He has given some presentations on Project Management and TQM at various venues. He has won few Talent/STAR performance awards and plays almost all the sports what are under the Sun. He hails from Vizag/ Hyderabad – India. His 3rd party tested Temperament Sorter results are below If you liked his presentation, tell others and if you have a comment, tell him. He can be reached at or U NEVER FAIL TILL U QUIT Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

4 Thank you for downloading my Presentation
3. Thank you note He wishes to thank Paul Perrone , Paulo Merson & Ramesh Behra for making this tutorial look the way it does. He wishes to thank to Katherine Ballantyne, Choi Kwan who volunteers to edit all of his Articles & Presentations. He wishes to thank Joerg Mueller, Muruganandam, CharlesJohnson & Venu Gadium who had volunteered to do the editing of this presentation. Special thanks to all his Managers at Pramerica and Purdential U.S. Thank you for downloading my Presentation Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. ARUNA SUNAYANA SADHGI his Parents Dr.Rao & Family his Brothers his Sisters & his Cousins DEDICATED TO Copyright 2004 Kanti Prasad All rights reserved

5 Copyright 2004 Kanti Prasad All rights reserved
4. Component Technology Components are deployable units that provide a business service to their clients. Each component provides an interface in the form of operations, properties and events Components can be developed in any language such as JAVA,C++,VB Components are frequently organized into application frameworks for vertical domains Component models such as Active X and EJB standardize communication and allow for prebuilt purchased components Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

6 5. Component Characteristics
Components Characteristics include Properties Reusability Operations Shareable Events Distributable Deployable Self Containment Self description Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

7 Copyright 2004 Kanti Prasad All rights reserved
6. Component P O E Components should have a mechanism for exporting Properties Operations Events Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

8 7. Deployable Components
Components are operation independent of Hardware The underlying operating system Their Application Server The network protocol they use Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

9 Copyright 2004 Kanti Prasad All rights reserved
8. Reusable Components Component services can be used as a part of business logic of other components Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

10 Copyright 2004 Kanti Prasad All rights reserved
9. Shareable Components If multiple clients are using a component simultaneously, the component will provide the same quality of service to all the clients Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

11 10. Distributable Components
Components should provide services to clients running locally or remotely Remote CLIENTS EJB Container EJB Local CLIENTS Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Remote CLIENTS Possible Remote CLIENTS Remote CLIENTS Copyright 2004 Kanti Prasad All rights reserved

12 11. SelfContained Components
Components should only contain the code necessary to implement their services Infrastructure services should be injected by the execution environment Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

13 12. Standard Infrastructure Needs
Standard infrastructure services include Directory Services Distributed transaction management Security management Concurrent access management Persistence management Resource pooling (e.g. DB connections) Administration interface Load Balancing Fault tolerance Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

14 Application Server products are mostly
13. Applicatoin Servers An application server provides the infrastructure and services to run components/applications Application Server products are mostly J2EE based solutions Non-J2EE solutions (PHP, Cold Fusion, Perl, etc.) Microsoft Solutions (COM, ASP.Net VB.Net,C# etc.) Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

15 Copyright 2004 Kanti Prasad All rights reserved
14. Object Pooling An application server may create a pool of bare objects that may be used as EJBs when requests are made App Server EJB Container Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. EJB EJB EJB CLIENT Pool DB EJB EJB Network CLIENT EJB Copyright 2004 Kanti Prasad All rights reserved

16 15. Directory of Application Servers
Application Servers provide clients access to software or other applications that run only on the server Examples include web servers, servers and database servers Popular Application Servers are: I.B.M. Web Sphere BEA Web Logic Sun Java System Application Server 7.x Jboss The full list with vital statistics are available at Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

17 16. Container A Container : &
Container means a pre developed Software Fish cannot survive outside water & EJB’s cannot survive outside containers A Container : provides the environment in which a bean executes generates Home Object generates EJB Object manages individual bean instances Implicit Middleware gained through declaration & To increase capability. clustering is taken care by the vendor Container provides System services like Transaction Persistence Security Connection Pooling Threading Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. App Server EJB Container EJB EJB EJB Container intercepts requests Network STUB CLIENT Container knows what to do, as you describe everything in a special descriptor file Copyright 2004 Kanti Prasad All rights reserved

18 17. J2EE Overview J2EE Container/Server J2EE Interfaces
Deployment Descriptors (DDs) Web Server Independence Enterprise Components Application Server Independence services standards component-based J2EE Container/Server Database Independence Enterprise Resource Management Services Deploy Tools J2EE Interfaces Management Services Distributed Communication Services Deployment/Configuration Common Programming Services J2SE Language/Interfaces Data J2SE Runtime Operating System Independence Operating System Platform Hardware Independence Hardware Platform Copyright 2004 Kanti Prasad All rights reserved

19 18. J2EE 1.4 APIs J2EE defines a model for developing multi-tier, web based, enterprise applications with distributed components Applet Container Web Container RMI/ IIOP EJB Container HTTP/S JSP Servlet EJB Applet JSP Servlet ENGINE J M S Mgmt J M S Mgmt JAX- RPC J A X R J A C W E B S Java Mail J T A J N D I C O N J D B C JAX- RPC J A X R J A C W E B S Java Mail J T A J N D I C O N J D B C J2SE JMX JMX SAAJ JAF SAAJ JAF Application Client Container J2SE J2SE HTTP/S 4 TIER Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. 3 TIER Client RMI/ IIOP EIS JAX- RPC J A X R J M S W E B S Mgmt C O N J D B C DAO JMX SAAJ DB J2SE 2 TIER MainFrames For all the APIs refer Copyright 2004 Kanti Prasad All rights reserved

20 19. Enterprise JavaBeans Model
EJB is Sun’s J2EE transactional, vendor-neutral, enterprise component architecture providing Modelling of business entities as well as synchronous and asynchronous processes Persistence via explicit code (bean-managed) or via services of the EJB server (container-managed) Vendor neutrality and inter operability XML driven deployment and configuration Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. EnterpriseJava Beans != Java Beans EJBs need a Container EJBs are deployable components EJBs are assembled to form a complete Appl EJBs are based on RMI IIOP and JNDI Technologies JBs do not need a container JBs are development components JBs are Classes with no argument constructor JBs have a get and a set method on them Copyright 2004 Kanti Prasad All rights reserved

21 20. EJB Overview EJB simplified distributed development
Develop EJB implementation logic Define Home/Local Remote/Local interfaces Container delegates client calls Container manages resources/lifecycle/callbacks J2EE EJB Container/Server EJB Client EJB Impl LocalHome Local create remove find invoke timeout passivate activate load store Client Process create remove find invoke EJB Client Home STUB STUB create remove find Network EJB Pool Remote Delegate Delegate Delegate invoke Delegate Copyright 2004 Kanti Prasad All rights reserved

22 Copyright 2004 Kanti Prasad All rights reserved
21. When to use EJB If any of these requirements hold for your application the application must be scalable and distributable Transactions will be required to ensure data integrity the application will have a variety of clients Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

23 22. Java Naming and Directory Interface (JNDI)
Provides a standardized way of accessing resources in a distributed environment Protocol and naming service agnostic DNS NDIS LDAP X.500 Implemented by the javax.naming package and three other packages below it javax.naming.InitialContext is the entry point to the EJB Server bind – associates a name with an object lookup – finds an object given the name Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

24 Copyright 2004 Kanti Prasad All rights reserved
23. EJB Specification The EJB specification defines interfaces between the EJB and its container the container and the application server the container and the client Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

25 24. EJB Roles Service & Tool Provider EJB Provider
provides Server, Container and integrates with distributed facilities EJB Provider creates EJB components Application Assembler assembles apps from per-built EJB comp Deployment Specialist deploys apps and understands architecture issues Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. deploys system supplies tools builds application Application Assembler Tools Provider Deployer System Administrator maintains deployment supplies Application Server develops EJBs EJB Provider Application Server Provider Copyright 2004 Kanti Prasad All rights reserved

26 25. EJB Design Approaches EJB model is based on three basic design approaches for building distributed component systems Stateless server approach Session-oriented approach Persistent Object approach Implementing one of these interfaces indicates your JAVA class is an EJB. The EJB specification provides these as Stateless session Beans Message driven beans Stateful session Beans Entity Beans All EntityBeans All SessionBeans All MessageDrivenBeans implements Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Interface implements Interface implements Interface javax.ejb.EntityBean javax.ejb.SessionBean javax.ejb.MessageDrivenBean extends extends extends javax.ejb.EnterpriseBean interface extends It is only a marker Interface and there are no methods to Implement. As all these are extending the two Interfaces hence they have the behavior of both the Interfaces. java.io.Serializable Serialization is the reason EJB is distributable. Copyright 2004 Kanti Prasad All rights reserved

27 (Business Logic Class)
26. EJB Architecture Server A App Server SERVICES Naming Service such as LDAP Server B JNDI Initial Context Naming Transaction Persistence Security 2 H H EJB Container 8 H Home Interface Home Object (FACTORY) 10 EIS 3 1 4 5 H EJB (Business Logic Class) 6 creates DB Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Home Obj Stub RMI/IIOP 9 MainFrames Remote Interface EJB Object (Wrapper) Application Client delegates request 7 EJB Obj Stub 11 we have written Container implements/autogenerates code for the Interfaces We will write only this Container manages TRANSACTIONS, PERSISTENCE, SECURITY & POOLING Copyright 2004 Kanti Prasad All rights reserved

28 27. EJB Flow Chart C C Start invokes a business method
thru Remote Stub ask JNDI Server for the Home Object 1 6 JNDI Server returns ref of Home Stub 2 goes to the JNDI Server and gets the EJB Object 7 ask Home for the EJB Object 3 Remote Interface then wraps a request to the Bean class Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. 8 creates EJB Object 4 Clients receives the required info returns reference of Remote Stub 5 9 C End Copyright 2004 Kanti Prasad All rights reserved

29 Copyright 2004 Kanti Prasad All rights reserved
28. Client View of EJB ENTITY BEANS are like NOUNS as they represent data or data related logic. App Server EJB Container e.g Bank teller Credit Card authorization EJB Home or EJB Local Home Session Bean instance EJB Object or EJB Local Object e.g Bank account balance Purchase order Application Client Entity Bean instance RMI/ IIOP JMS Destination e.g Stock trade messages Work flow messages Message Driven Bean instance Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. SESSION BEANS are like VERBS as they represent action or business process related logic. MESSAGE DRIVEN BEANS have message oriented logic. If all the processing is done in the same Application server then we use EJB Local(Object & Home) interfaces. Using local interfaces are optional. Local interfaces pass by REFERENCE and EJB (Object/Home) pass by VALUE. Using local interfaces avoids stubs, skeletons, network and so it is faster. Copyright 2004 Kanti Prasad All rights reserved

30 Copyright 2004 Kanti Prasad All rights reserved
29. EJB Client EJB clients utilizes the Java Naming and Directory Interface (JNDI) to look up for the references to home interfaces use home and remote EJB interfaces to utilize all EJB-based functionality Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

31 Copyright 2004 Kanti Prasad All rights reserved
30. EJB Home Interface EJB home interfaces extends javax.ejb.EJBHome EJB home interfaces provide operations for clients to create EJBs remove EJBs find handles to EJB remote interface objects have its stub placed into JNDI at startup Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

32 Copyright 2004 Kanti Prasad All rights reserved
31. EJB Remote EJB remote interfaces extends javax.ejb.EJBObject EJB remote interfaces provide business-specific functionality of an EJB are similar to RMI Remote interface Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

33 Copyright 2004 Kanti Prasad All rights reserved
32. EJB Implementation EJB implementation Class in which EJB developer codes the business methods defined in the bean’s component interface(s) to provide any application specific business method invocation creation removal finding activation passivation, database storage database loading logic Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

34 Copyright 2004 Kanti Prasad All rights reserved
33. Session Context The Container has already reference to the bean The bean interacts with the Container through SessionContext and retrieves home interfaces gets and sets transactions attributes obtains security attribute The setSessionContext method is used to inform the bean about the session context Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

35 Copyright 2004 Kanti Prasad All rights reserved
34. Stateless Session EJB Stateless session EJBs have the following behaviour provide a single use service do not maintain state on behalf of the client are relatively short lived do not survive EJB server crashes any two instances of the same stateless session EJB type are always identical each instance can be shared by multiple clients Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

36 35. Stateless Session EJBs View
J2EE EJB Container/Server Stateless Session EJB Client Client Process LocalHome Local Logic Network EJB Client Home input Remote EJB Pool output EJB Impl Developer View EJB gets requests and generates responses An instance can service multiple clients over time EJB Client Developer View creates it, uses it and then it’s done EJB Container View can pull instances from pool upon client request can shrink/grow pool as needed A few pooled beans can service thousands of clients

37 36. Life Cycle of Stateless Session Bean
Each method call is an invocation from the container to the Bean Client called remove() on the EJB object (or the client times out) Bean Instance does not exiist Container decided it needs more instances in the pool to service clients Class.newInstance() ejbRemove() setSessionContext() ejbCreate() Pool of equivalent method ready instances Client called another Transactional business method on the EJB Object. Transactional Business Method

38 37. Stateful Session EJBs View
J2EE EJB Container/Server Stateful Session EJB Client Client Process LocalHome Local Logic State Network EJB Client Home input Remote EJB Pool output EJB Impl Developer View EJB gets requests and generates responses An instance can service multiple clients over time EJB Client Developer View creates it, uses it and then it’s done EJB Container View can pull instances from pool upon client request can shrink/grow pool as needed

39 38 .Life Cycle of Stateful Session Bean
Each method call is an Invocation from the container to the Bean Client called remove() on the EJB object (or the client times out) Bean Instance does not exiist Client called create(args) on the home Interface. Class.newInstance() Container’s limit of instantiated beans are reached, so it must swap your bean out. ejbRemove() setSessionContext() Client times out Client called a non-transactional business method on the EJBObject ejbCreate(args) Non-Transactional Business Method ejbPassivate() Bean instance is ready to service method calls Bean instance is in the passive state Client called a transactional business method on the EJB Object ejbActivate() If we implement Javax.ejb.SessionSynchronization then we need to write these methods. beforeCompletion() Client called a method on a passivated bean, so Container must swap your Bean back in afterCompletion(true) afterCompletion(false) afterBegin() If transaction ended in a commit.. Bean instance is within a transaction and ready to service method calls We need to write all the methods that are there in the Implemented class If transaction ended in an abort. Client called another Transactional business method on the EJB Object. Transactional Business Method

40 Copyright 2004 Kanti Prasad All rights reserved
39. Stateful vs Stateless Stateful Bean Stateless Bean A stateful bean contains a conversational state that is retained across method calls and transactions. The create method takes arguments e.g. create(String id) , create(int I , String id) There can be one or more arguments in a create method A stateless bean does not have any state between calls to its methods. The create method does not take arguments e.g create() There can be no arguments in a create method e.g An EJB that unzips 100 bytes of data An EJB that checks to see if a stock symbol is valid e.g An EJB that books a flight and rents a car at a travel agent’s web site. Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Method by method comparison can be seen in EJB20Matrix.doc at Copyright 2004 Kanti Prasad All rights reserved

41 Copyright 2004 Kanti Prasad All rights reserved
40. Entity Bean Entity Bean has the following behaviour They are a representation of persistent data They can survive a crash Multiple clients can be using EJBs that represent the same data The EJB instance contains a copy of the data in the persistent store has a Primary key like in a Database record. Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

42 (BMP = Bean-Managed Persistence)
41. BMP Entity EJBs (BMP = Bean-Managed Persistence) J2EE EJB Container/Server Entity Bean (BMP) EJB Client LocalHome Local Client Process Hand Coded Logic Network EJB Client Home EJB Pool Remote input output data Persisted objects (via hand-coding) EJB Impl Developer View encapsulates data from a data source as objects implements object-relational mapping (often JDBC) implements inserts, deletes, queries and updates EJB Client Developer View creates, finds, updates and removes entity objects EJB Container View persists and manages concurrent access of instances

43 Copyright 2004 Kanti Prasad All rights reserved
42. Primary key class Applicable only to entity beans Uniquely differentiates instances sharing the same EJBHome Class must be a legal value type in RMI-IIOP Implements java.io.Serializable all the members should be public It should implement hashCode() and equals(.. ) methods does not implement java.rmi.remote Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

44 Copyright 2004 Kanti Prasad All rights reserved
43. Shared Entity Bean When multiple clients share an Entity EJB they receive their own instance share the underlying data do not have to handle synchronization Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. App Server EJB Container CLIENT DB EJB Network CLIENT EJB Copyright 2004 Kanti Prasad All rights reserved

45 44. Life Cycle of BMP Entity Bean
Each method call is an Invocation from the container to the Bean Does not exiist Container decided it needs another Entity Bean insinstance Container decided it doesn’t need the Entity Bean instance anymore newInstance() unsetEntityContext() setEntityContext() JVM will garbage collectt and call finalize() Client called instance independent ejbHome() Business method Client called a finder Method on the home interface Pooled ejbHome() ejbFind() Client called create() on the home interface (this will Create new database data) Activates the Bean Passivates the Bean Client called remove() on the EJB object (this will destroy Database data) ejbCreate() ejbActivate() ejbStore()\ ejbRemove() Container determined that the database is out of synch with the bean. The Bean needs to load the new Database data. ejbPostCreate() ejbLoad() ejbPassivate() Container determined that the database is out of synch with the bean. The Bean needs to store its Data into the Database Ready ejbLoad() ejbStore() Client called a business method on a EJBObject Business Method

46 (CMP = Container-Managed Persistence)
45. CMP Entity EJBs (CMP = Container-Managed Persistence) J2EE EJB Container/Server Entity Bean (CMP) EJB Client LocalHome Local Client Process Generated Logic Network EJB Client Home EJB Pool Remote input output Persistence DDs Persisted objects (via container services) data EJB Impl Developer View specifies CMP fields and relations among entities in DDs specifies queries via EJB-QL in DDs uses tools to map standard object view to specific relational view EJB Client Developer View creates, finds, updates and removes entity objects EJB Container View persists and manages concurrent access of instances

47 46. Life Cycle of CMP Entity Bean
Each method call is an Invocation from the container to the Bean NOTE : BMP has no ejbSelect() does not exiist Container decided it needs another Entity Bean in Container decided it doesn’t need the Entity Bean instance anymore newInstance() unsetEntityContext() Client called a finder method on the home Interface, or bean called its own ejbSelect() method to locate Database data setEntityContext() JVM will garbage collectt and call finalize() Client called instance independent ejbHome() Business method Pooled ejbHome() ejbFind() or ejbSelect() Client called create() on the home interface (this will create new database data) Activates the Bean Passivates the Bean Client called remove() on the EJB object (this will destroy Database data) ejbCreate() ejbActivate() ejbStore()\ ejbRemove() Container determined that the database is out of Synch with the bean. The Bean needs to load the new Database data. ejbPostCreate() ejbLoad() ejbPassivate() Container determined that the database is out of Synch with the bean. The Bean needs to store its Data into the Database Ready ejbLoad() ejbStore() Client called a business method on a EJBObject Business Method Or ejbSelect()

48 Copyright 2004 Kanti Prasad All rights reserved
47. BMP vs CMP Bean Managed Persistance Container Managed Persistance BMP offers a tactical approach The developer takes care of handling persistence BMP uses hard coded queries so we can optimize our queries CMP is more strategic Vendor takes care of everything by using O-R or OODB mappings using metadata. A developer cannot optimize performance as the vedor takes care of it We should start developing CMP beans, unless we require some kind of special bean, like multi-tables, that cannot be completely realized with a single bean. Then when we realize that we need something more or that we prefer handling the persistence (performance issue are the most common reason), we can change the bean from a CMP to a BMP Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Method by method comparison can be seen in EJB20Matrix.doc at Copyright 2004 Kanti Prasad All rights reserved

49 Copyright 2004 Kanti Prasad All rights reserved
48. Message Driven Bean MDB has the following behaviour Is stateless is a JMS listener when a JMS message arrives the method onMessage() is executed does not survive EJB server crashes provides a single-use service is relatively short lived is only a bean class – no interfaces Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

50 J2EE EJB Container/Server
49. Message Driven EJBs J2EE EJB Container/Server Messaging Service Message-Driven Bean Message Queue Handler Logic Producer Process Network Message input Message Producer Messaging API Message Message Listener EJB Pool Asynchronous messaging EJB Impl Developer View gets async requests via messaging paradigm-specific interface An instance can service multiple clients over time EJB Client Developer View Messages sent to endpoint & handled by messaging service Specific to particular messaging paradigm used EJB Container View pulls instance from pool and delivers message

51 50. Life Cycle of Message Driven Bean
Each method call is an Invocation from the container to the Bean Does not exiist Container decided it needs another Message DrivenBean Instance newInstance() ejbRemove() setMessageDrivenContext() ejbCreate() Pooled onMessage()

52 Copyright 2004 Kanti Prasad All rights reserved
51. Deployment Deployment involves taking an EJB compliant bean and creates XML that describes the EJB packages the bean and XML into a Jar generates container files for the EJB configures properties of the EJB Server Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Declaring without programming helps the application assembler to change the XML file easily. BEAN Provider declares components’ middleware service requirements in a DEPLOYMENT DESCRIPTOR File. Bean Provider describes how the Container should perform the LifeCycle Management, Persistence, Transaction and Security. Copyright 2004 Kanti Prasad All rights reserved

53 52. Other interfaces and classes
Local interfaces are used for access within server context javax.ejb.EJBLocalHome javax.ejb.EJBLocalObject Interfaces for serializing EJB references HomeHandle - reference to EJBHome Handle - reference to EJBObject EJBMetaData interface provides mechanism to gather information about the bean reference to EJBHome object Home, component interface and primary key classes functions to determine bean type E.g.: Inter component calls Servlet invocation Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

54 Copyright 2004 Kanti Prasad All rights reserved
53. Exceptions System exceptions are unchecked and propagated to the client as java.rmi.RemoteException Application exceptions are checked and propagated to the client as a descendant of java.lang.Exception EJB-specific exceptions include FinderException, CreateException, RemoteException (all in javax.ejb package) Business method exceptions are at the discretion of the EJB developer Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

55 Copyright 2004 Kanti Prasad All rights reserved
EXAMPLE 1 STATELESS BEAN Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

56 Copyright 2004 Kanti Prasad All rights reserved
54. Steps to Develop an EJB C Start Configure your EJB Server. E.g DB connections thread pooling etc Then copy the EJB Jar file Write .java files for the BEAN, HOME and REMOTE interfaces 1 5 2 Write the Deployment descriptor Start your EJB container and confirm that it has loaded the EJB Jar file. 6 Compile all the STEP 1 files into .class files 3 Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Connect to your EJB by writing a test Client .java file compile it and run it . 7 Using the Jar utility create an EJB Jar file containing STEP 2 & STEP 3 files 4 End C Please download the trial Application Server software from the links provided on the Reference slide at the end. Copyright 2004 Kanti Prasad All rights reserved

57 55. Hello World Object Model using RMI
We will apply the previous slide flow chart procedure to make up our first EJB example These Interfaces comes with Java 2 Platform java.rmi.Remote java.io.Serializable These Interfaces comes with EJB distribution Javax.ejb.EnterpriseBean Javax.ejb.EJBObject Javax.ejb.EJBHome Javax.ejb.SessonBean Supplied by the Bean Provider / Developer/ We will write ! We need to CODE only this block Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Hello World Bean Implementation Class Hello world Remote Interface Hello World Home Interface Generated for us by the Container verdor’s tools NOTE : Object implementation is Vendor specific. The container may implement either A single object for each client or A single object for all the clients. Hello world EJB Object Hello World Home Object Copyright 2004 Kanti Prasad All rights reserved

58 56. Hello World Object Model using LOCAL
If all the processing is done in the same Application server then we use EJB Local (Object & Home) interfaces. Using local interfaces are optional. Local interfaces pass by REFERENCE and EJB (Object/Home) which is the previous slide model you saw will pass by VALUE. As these interfaces does not extend Java.rmi.Remote the overhead of creating stubs, skeletons,network traffic is avoided and so it is faster but the drawback is if our code relies on Local interfaces then we cannot call a bean remotely. No Network so LOCAL IMROVES PERFORMANCE These Interfaces comes with Java 2 Platform java.rmi.Remote java.io.Serializable These Interfaces comes with EJB distribution Javax.ejb.EnterpriseBean Javax.ejb.EJBLocalObject Javax.ejb.EJBLocalHome Javax.ejb.SessonBean Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Supplied by the Bean Provider / Developer/ We will write ! We need to CODE only this block Hello World Bean Implementation Class Hello world LocalInterface Hello World Local Home Interface Generated for us by the Container verdor’s tools NOTE : Object implementation is Vendor specific. The container may implement either A single object for each client or A single object for all the clients. Hello world EJB LocalObject Hello World Local Home Object Copyright 2004 Kanti Prasad All rights reserved

59 57. HelloBean Home Interface
EJB Example requirement : When the client interacts with the EJB we need to return a “Hello World” greeting. To provide an EJB with the above requirement we have to create Remote & Home Interfaces , Bean Business logic class and a deployment descriptor. For clarity please see the previous slide Hello World Object Model using RMI. This is the Home Interface for the Home EJB (HelloBean). package examples ; import java.io.Serializable; import java.rmi.RemoteException; import javax.ejb.CreateException; import javax.ejb.EJBHome; public interface HelloHome extends javax.ejb.EJBHome { Hello create() throws java.rmi.RemoteException, javax.ejb.CreateException; } Rules of Java says package declaration should be at the beginning and ends with a semi colon Importing the required files Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Our interface HelloHome is extending EJBHome means it has all the behaviour of EJBHome Interface methods should end with a semicolon ; This method creates/manufactures the EJBObject and returns it . This create() method corresponds to the ejbCreate() method in HelloBean. Note In Home Interface we are throwing 2 exceptions Remote and Create . As for every Interface we need implementation, so Container will implement (autogenerate code) for this Home Interface for us, which is the EJBHome Object NOTE : Rules of Interfaces states that there should be no implementation so you will find only method signatures. Copyright 2004 Kanti Prasad All rights reserved

60 58. HelloLocalHome Interface
So now lets code the HelloLocalHome Interface This is the LocalHome Interface for the Home EJB (HelloBean). package examples ; import javax.ejb.EJBLocalHome; import javax.ejb.CreateException; import javax.ejb.FinderException; import java.util.Collection; public interface HelloLocalHome extends javax.ejb.EJBLocalHome { HelloLocal create() throws javax.ejb.CreateException; } Rules of Java says package declaration should be at the beginning and ends with a semi colon Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Our interface HelloLocalHome is extending EJBLocalHome means it has all the behaviour of EJBLocalHome As for every Interface we need implementation, so Container will implement (autogenerate code) for this Local Home for us, which is the LocalHome Object This method creates/manufactures the EJBLocal Object and returns it . This create() method corresponds to the ejbCreate() method in HelloBean. Note In LocalHome Interface we are throwing only Create and not Remote exception as there is no network Interface methods should end with a semicolon ; NOTE : Rules of Interfaces states that there should be no implementation so you will find only method signatures. Copyright 2004 Kanti Prasad All rights reserved

61 59. HelloBean Remote Interface
So lets code the Remote Interface Clients interact with the EJB Object through this Remote interface that is why we need to write this interface. package examples ; import java.util.*; import javax.ejb.EJBObject; import java.rmi.RemoteException; public interface Hello extends javax.ejb.EJBObject { public String hello() throws java.rmi.RemoteException; } Rules of Java says package declaration should be at the beginning and ends with a semi colon Importing the required files Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Our interface Hello is extending EJBObject means it has all the behaviour of EJBObject As our requirement wants a business logic to greet Hello World a single method would be sufficient . As Remote interface is used to interact with the Bean we need to mirror all the method signatures what are there in a Bean class so that is why we are writing only one method in this Remote interface. Note EJB specification states that all remote calls should throw RemoteException so we are throwing it. Interface methods should end with a semicolon ; As for every Interface we need implementation, so Container will implement (autogenerate code) for this Remote Interface for us, which is the EJBObject NOTE : Rules of Interfaces states that there should be no implementation so you will find only method signatures. Copyright 2004 Kanti Prasad All rights reserved

62 Copyright 2004 Kanti Prasad All rights reserved
60. HelloLocal Interface Clients interact with the EJB Object through this Local interface when there is no network involved.. package examples ; import javax.ejb.EJBLocalObject; public interface HelloLocal extends javax.ejb.EJBLocalObject { public String hello() ; } Rules of Java says package declaration should be at the beginning and ends with a semi colon Our interface Hello is extending EJBLocalObject means it has all the behaviour of EJBLocalObject Interface methods should end with a semicolon ; As our requirement wants a business logic to greet Hello World a single method would be sufficient . As Local interface is used to interact with the Bean we need to mirror all the method signatures what are there in a Bean class so that is why we are writing only one method in this Local interface. Note As there is no remote calls no Remote Exception is thrown Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. As for every Interface we need implementation, so Container will implement (autogenerate code) for this Local Interface for us, which is the EJB Local Object NOTE : Rules of Interfaces states that there should be no implementation so you will find only method signatures. Copyright 2004 Kanti Prasad All rights reserved

63 61. The Bean Class So now lets code the actual EJB Class
This is where we will code our Business logic package examples ; import java.util.*; import javax.ejb.*; public class HelloBean implements javax.ejb.SessionBean { private SessionContext ctx; public void ejbCreate() { System.out.println(“ejbCreate()”); } public void ejbRemove() { System.out.println(“ejbRemove()”);} public void ejbActivate() { System.out.println(“ejbActivate()”);} public void ejbPassivate() { System.out.println(“ejbPassivate()”); } public void setSessionContext(javax.ejb.SessionContext ctx) { this.ctx = ctx; } public String hello() { System.out.println(“Hello()”); return “Hello World! “ ; } } Rules of Java says package declaration should be at the beginning and ends with a semi colon Importing the required files NOTE : If it is Entity Bean we will implement javax.ejb.EntityBean and if it is Message driven bean we will implement javax.ejb.MessagedrivenBean Note : this is a class and not an Interface like the other two (Home / Remote). This is implementing SessionBean so it is a Session Bean As per the below note in red we need to write all the methods what are in javax.ejb.SessionBean . This ejbCreate() corresponds to the Homeobject Create(). NOTE : in Stateless Bean no arguments are sent There is nothing much to clean up. These are called Management or Call back methods Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. In Statelss Bean ejbActivate and ejbPassivate Do not apply Storing the Context in a variable so that it can be queried later . NOTE : Because it is a Session Bean we are using setSessionContext for Entity Bean we use setEntityContext and for Message Driven Bean we use setMessageDrivenContext. Our Business method which matches our Remote Interface method signature Java does not support multiple inheritance so you can extend only one class. To overcome this they had given us the Implementation option . So when we use implement we need to implement or write all the methods what are there in the interface we implemented. Copyright 2004 Kanti Prasad All rights reserved

64 62. The Deployment descriptor
THERE ARE MANY TOOLS WHICH CREATES THE DESCRIPTOR FOR US So now lets complete our EJB by writing the deployment descriptor. As a Bean provider we need to specify the Middleware needs through this descriptor. <!DOCTYPE ejb-jar PUBLIC “-//Sun Microsystems, Inc. // DTD Enterprise JavaBeans 2.0 // EN “ “ <ejb-jar> <enterprise-beans> <session> <ejb-name> Hello </ejb-name> <home>examples.HelloHome</home> <remote>examples.Hello</remote> <local-home>examples.HelloLocalHome</local-home> <local>examples.HelloLocal</local> <ejb-class>examples.HelloBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> </session> </enterprise-beans> </ejb-jar> XML Standard requirement The nickname for this particular Bean The fully qualified name of the Home Interface The fully qualified name of the Remote Interface Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. The fully qualified name of the Local HomeInterface The fully qualified name of the Local Interface The fully qualified name of the EJB Class Whether the session bean is stateful or stateless Copyright 2004 Kanti Prasad All rights reserved

65 63. The Client So now lets code our Client to access our simple stateless session bean. package examples; import javax.naming.Context; import javax.naming.InitialContext; import java.util.Properties; public class HelloClient { public static void main(String [] args) throws Exception{ Properties props = System.getProperties(); Context ctx = new InitialContext(props); Object obj = ctx.lookup(“HelloHome”); HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow( obj, HelloHome.class); Hello hello = home.create(); System.out.println(hello.hello()); hello.remove();}} Rules of Java says package declaration should be at the beginning and ends with a semi colon importing the necessary files As there is static key word this main method executes first before any other method in that class Assigning props variable with properties information for JNDI initialization Obtaining the JNDI initial context is the starting point for connection to a JNDI tree By passing environment properties we will choose our JNDI driver,network location of the server etc. Get a reference to the Home Object- the factory for Hello EJB Objects. Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. We are casting HelloHome here, as Home Objects are RMI-IIOP objects and so we Need to use a special RMI-IIOP cast. Use the factory to create the Hello EJB Object. We are then calling the hello() method On the EJB Object. The EJB object will delegate the call to the Bean,receive the Results and return it to us . We then print it on the screen. Once we are done with the EJB Object, we can remove it. NOTE : To call Local Interface you need not cast with the PortableRemoteObject. So the block in red will be changed to Object obj = ctx.lookup(“java:comp/env/HelloLocalHome”); ( to get a ref to LocalHome Object) HelloLocalHome home = (HelloLocalHome)obj; Copyright 2004 Kanti Prasad All rights reserved

66 Or manually run C:\>Jar cf HelloWorld.jar *
64. EJB Jar File The folder structure within the Ejb-jar file is META-INF/MANIFEST.MF META-INF/ejb-jar.xml examples/HelloBean.class examples/HelloLocalHome.class examples/HelloLocal.class examples/Hello.class Properties File Remote/Local Interface HomeLocalHome Interface Enterprise Bean Class Jar file Jar Creator Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Deployment Descriptor Jar Manifest DEPLOYED Or manually run C:\>Jar cf HelloWorld.jar * Jar file is a .ZIP compression format . META-MF file is a listing file automatically created by the Jar utility. Please read the Deployment instructions provided by the Application server as it is Vendor specific Copyright 2004 Kanti Prasad All rights reserved

67 65. EJB Application Assembler
.JAR Deployment Descriptor .WAR Jar file Deployment Tool JAR ARC HIEVE (.jar) WEB ARCHIEVE (.war) EJB-JAR.XML REMOTE WEB.XML HOME Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. HTML Enterprise Archive (.EAR Files) (Application.XML) JSP EJB Servlets Copyright 2004 Kanti Prasad All rights reserved

68 Copyright 2004 Kanti Prasad All rights reserved
EXAMPLE 2 STATEFUL BEAN Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

69 66. Stateful Session Remote Interface
package declaration should be in the beginning package samples.ejb.stateful.simple.ejb; import java.util.*; import javax.ejb.EJBObject; import java.rmi.RemoteException; import samples.ejb.stateful.simple.tools.BookException; public interface Cart extends EJBObject { public void addBook(String title) throws RemoteException; public void removeBook(String title) throws BookException, RemoteException; public Vector getContents() throws RemoteException; } Importing the required classes Remote Cart is extending EJBObject means Cart has all the behaviour of it Our bean class CartBean methods are mirrored here Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. EJB spec says all remote interface methods need to throw remote exception There will not be any implementation in Interfaces Copyright 2004 Kanti Prasad All rights reserved

70 67. Stateful Session Home Interface
package declaration should be in the beginning package samples.ejb.stateful.simple.ejb; import java.io.Serializable; import java.rmi.RemoteException; import javax.ejb.CreateException; import javax.ejb.EJBHome; public interface CartHome extends EJBHome { Cart create(String person) throws RemoteException, CreateException; Cart create(String person, String id) throws RemoteException, CreateException; } Importing the required classes CartHome is extending EJBHome means CartHome has all the behaviour of it Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. In a Stateful Bean you can have more than one create method taking arguments In our bean class CartBean these represent ejbCreate(String person) & ejbCreate(String person, String id) EJB spec says all Home interface methods need to throw remote & create exceptions There will not be any implementation in Interfaces Copyright 2004 Kanti Prasad All rights reserved

71 68. Stateful Session Bean Class
package samples.ejb.stateful.simple.ejb; import java.util.*; import javax.ejb.*; import samples.ejb.stateful.simple.tools.BookException; import samples.ejb.stateful.simple.tools.IdVerifier; public class CartBean implements SessionBean { String customerName; String customerId; Vector contents; public void ejbCreate(String person) throws CreateException { if (person == null) { throw new CreateException("Null person not allowed."); } else { customerName = person; } customerId = "0"; contents = new Vector(); package declaration should be in the beginning Importing the required classes CartBean Class is implementing sessionbean means this bean class is a session bean We defined this method in the Cart remote interface. This also represents the Home create(String person) method Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. as this is the Bean class we will implement the business logic here NOTE : AS we are implementing and not extending we need to write all the methods that are there in the Sessionbean Copyright 2004 Kanti Prasad All rights reserved

72 69. Stateful Session Bean Class
public void ejbCreate(String person, String id) throws CreateException { if (person == null) { throw new CreateException("Null person not allowed."); } else { customerName = person; } IdVerifier idChecker = new IdVerifier(); if (idChecker.validate(id)) { customerId = id; throw new CreateException("Invalid id: " + id); contents = new Vector(); public void addBook(String title) { contents.addElement(title); public void removeBook(String title) throws BookException { boolean result = contents.removeElement(title); if (result == false) { throw new BookException(title + " not in cart."); This also represents the Home create(String person, String id) method we defined We defined this method in the Cart remote interface // This block is a supporting business method written in idVerifier class The new operator is instantiating the instance of a class We are calling the validate(id) method from the class ID Verifier Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. We defined this method in the Cart remote interface We defined this method in the Cart remote interface We defined contents as a vector Copyright 2004 Kanti Prasad All rights reserved

73 70. Stateful Session Bean Class
We defined this method in the Cart remote interface public Vector getContents() { return contents; } public CartBean() {} public void ejbRemove() {} public void ejbActivate() {} public void ejbPassivate() {} public void setSessionContext(SessionContext sc) {} Bean class constructor We need to write these methods as we are implementing SessionBean Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Rules of implement states we need to implement all methods that are there in the implemented interface Copyright 2004 Kanti Prasad All rights reserved

74 71. Stateful Deployment Descriptor
THERE ARE MANY TOOLS WHICH CREATES THE DESCRIPTOR FOR US <?xml version="1.0" encoding="UTF-8"?> <!-- Copyright 2004 Sun Microsystems, Inc. All rights reserved. SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. --> <ejb-jar version="2.1" xmlns=" xmlns:xsi=" xsi:schemaLocation=" <display-name>CartJAR</display-name> <enterprise-beans> <session> <display-name>CartEJB</display-name> <ejb-name>CartEJB</ejb-name> <home>samples.ejb.stateful.simple.ejb.CartHome</home> <remote>samples.ejb.stateful.simple.ejb.Cart</remote> <ejb-class>samples.ejb.stateful.simple.ejb.CartBean</ejb-class> <session-type>Stateful</session-type> <transaction-type>Container</transaction-type> <security-identity> <use-caller-identity/> </security-identity> </session> </enterprise-beans> required by any XML document The nickname for this particular Bean The fully qualified name of the Home Interface The fully qualified name of the Remote Interface Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. The fully qualified name of the EJB Class Bean type is mentioned here Closing session and ejb Copyright 2004 Kanti Prasad All rights reserved

75 72. Stateful Deployment Descriptor
<assembly-descriptor> <container-transaction> <method> <ejb-name>CartEJB</ejb-name> <method-intf>Remote</method-intf> <method-name>getContents</method-name> </method> <trans-attribute>Required</trans-attribute> </container-transaction> <method-name>removeBook</method-name> <method-params> <method-param>java.lang.String</method-param> </method-params> <trans-attribute>NotSupported</trans-attribute> Passing Bean class methods and parameter info Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Passing Bean class methods and parameter info Copyright 2004 Kanti Prasad All rights reserved

76 73. Stateful Deployment Descriptor
<container-transaction> <method> <ejb-name>CartEJB</ejb-name> <method-intf>Remote</method-intf> <method-name>addBook</method-name> <method-params> <method-param>java.lang.String</method-param> </method-params> </method> <trans-attribute>Required</trans-attribute> </container-transaction> </assembly-descriptor> </ejb-jar> Passing Bean class methods and parameter info Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

77 74. Stateful Session Client
package declaration should be in the beginning package samples.ejb.stateful.simple.ejb; import java.util.*; import javax.naming.Context; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; public class CartClient { public static void main(String[] args) { try { Context initial = new InitialContext(); Object objref = initial.lookup("java:comp/env/ejb/SimpleCart"); CartHome home = (CartHome)PortableRemoteObject.narrow(objref, CartHome.class); Cart shoppingCart = home.create("Duke DeEarl","123"); shoppingCart.addBook("The Martian Chronicles"); shoppingCart.addBook("2001 A Space Odyssey"); shoppingCart.addBook("The Left Hand of Darkness"); Vector bookList = new Vector(); bookList = shoppingCart.getContents(); Importing the required classes Client class As static is there this main method will execute first The new operator is instantiating the instance of a class Looking into JNDI Casting with a suitable RMI IIOP object Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Creating the object adding books to the object Invoking the bean class method through remote interface Cart Copyright 2004 Kanti Prasad All rights reserved

78 75. Stateful Session Client
We defined booklist as a vector Enumeration enumer = bookList.elements(); while (enumer.hasMoreElements()) { String title = (String) enumer.nextElement(); System.out.println(title); } shoppingCart.removeBook("Alice in Wonderland"); shoppingCart.remove(); System.exit(0); } catch (BookException ex) { System.err.println("Caught a BookException: " + ex.getMessage()); } catch (Exception ex) { System.err.println("Caught an unexpected exception!"); ex.printStackTrace(); System.exit(1); After storing in the variable “title” we are printing it Removing a particular book using the bean class method removeBook through remote interface Cart –as we defined it this way Cart shoppingCart = home.create("Duke DeEarl","123"); Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. We had written a new class BookException and using its method to catch any errors Copyright 2004 Kanti Prasad All rights reserved

79 Copyright 2004 Kanti Prasad All rights reserved
76. Book Exception package samples.ejb.stateful.simple.tools; public class BookException extends Exception { /** * Default constructor. */ public BookException() { } * Constructor with a <code>String<code> as a parameter. msg message, describing the exception. public BookException(String msg) { super(msg); Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

80 Copyright 2004 Kanti Prasad All rights reserved
77. ID Verifier package samples.ejb.stateful.simple.tools; public class IdVerifier { /** * Default constructor. */ public IdVerifier() { } public boolean validate(String id) { boolean result = true; for (int i = 0; i < id.length(); i++) { if (Character.isDigit(id.charAt(i)) == false) result = false; return result; Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

81 Copyright 2004 Kanti Prasad All rights reserved
ALL EXAMPLES CAN BE SEEN AT Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

82 Copyright 2004 Kanti Prasad All rights reserved
78. Component Comparison Component Distributability EJB Can implement the Remote or Local Interface ActiveX Uses Microsoft’s architecture for determining how clients’ invocation requests are sent to components. DCOM used as underlying transport mechanism CORBA ORB makes use of GIOP and other protocols to perform IPC Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

83 Copyright 2004 Kanti Prasad All rights reserved
79. Component Comparison Components provide interfaces in the form of Operations EJB exports operations through Remote Interface ActiveX exports operations in the same interface CORBA exports methods through Interface Repository Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

84 Copyright 2004 Kanti Prasad All rights reserved
80. Component Comparison Self – Container Components EJB Containers inject code to handle transactions, database management, security, distributability and other customisable services. Containers can be provided independent of App Server and EJB providers ActiveX Transactions, database management, legacy integration have to be coded into the logic of the component. Security policy can be inherited from NTLM. Transactions can be aided through MTS CORBA CORBAServices have different APIs. CORBAServices can be complicated to code with. CORBAServices are not supported by all ORBs Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

85 Copyright 2004 Kanti Prasad All rights reserved
81. Component Comparison Components provide interfaces in the form of Properties. EJB Properties are not explicitly exported but can be mimicked through accessor operations ActiveX exports Properties in the same interface CORBA Properties not explicitly exported but can be mimicked through attributes Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

86 Copyright 2004 Kanti Prasad All rights reserved
82. Component Comparison Components provide interfaces in the form of Events. EJB Events supported through JMS with Message Driven Bean ActiveX exports Events in the same interface CORBA Events supported through Event Service but cannot be exported Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

87 Copyright 2004 Kanti Prasad All rights reserved
83. Component Comparison Component Reusability EJB Incorporating the contents of an EJB can be done in two ways: by having the new EJB use the services of an old EJB as a direct client or by writing an EJB class that inherits from an existing one These two methods of leveragability give developers maximum flexibility Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

88 Copyright 2004 Kanti Prasad All rights reserved
84. Component Comparison Component Reusability Active X Incorporating the contents of an ActiveX can be done in two ways: by having the new ActiveX use the services of an old ActiveX as a client or by Delegation The Components being reused must be registered on the development machine Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

89 Copyright 2004 Kanti Prasad All rights reserved
85. Component Comparison Component Reusability CORBA Every CORBA object has to have its own interface definition CORBA objects can use the services of other Objects No mechanism for inheritance or Object reuse inherently supported, though Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

90 Copyright 2004 Kanti Prasad All rights reserved
86. Component Comparison Components Shareability EJB Application Server makes multiple instances of EJB Objects. Client contexts can be stored in different thread contexts. Different types of EJBs identify levels of shareability. ActiveX uses Microsoft's in–process/out-of-process architecture for sharing multiple ActiveX components and Client components. CORBA ORB makes multiple instances of CORBA objects. Clients’ contexts are managed by ORB but can behave differently based upon vendor’s Implementation. Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved

91 87. Conclusion CONGRATULATIONS!
We successfully completed a Tour on EJB . We looked at how an EJB is identified. How many different types of EJBs’ are there and what each EJB type implements. Why LocalInterfaces were introduced. We disected the EJB and went deeper into each part i.e. BEAN Class, Remote Interface, EJB Object, Local Object, Local Interface, Home Object. We looked Into the deployment descriptor and also seen all the files in EJB–Jar. We looked into each Beans Methods and also learned why we needed those methods. We had done 2 different Beans examples and we were directed to the Web links where all the examples are demonstrated. Once you can get an idea of all the Interfaces, methods & exceptions raised, you can attempt to try some examples to get familiar and master EJB. There are nearly 100s’ of Application servers but in this presentation you can see a few majorly used AppServers sample implementation web links. Just download any one of them and try out for yourself. Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. CONGRATULATIONS! Now you know as much as he know of EJB If you have any comments or appreciations then please him at He likes to hear your feed back! Copyright 2004 Kanti Prasad All rights reserved

92 Copyright 2004 Kanti Prasad All rights reserved
88. References Application Server Information , EJB Documentation & Tutorials are found here Notes on Deploying on different Application Servers. The Art of EJB Deployment Most of EJB’s related information can be seen at Mastering Enterprise Java Beans by Ed Roman , Scott Ambler & Tyler Jewel. EJB Documentation Application Servers download information . Most of them are either free or have a 60 day trial version For JBOSS Open Source go to SUN’s downloads and examples , Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Covers 90 % of the MARKET BEA WebLogic downloads and examples , WebSphere downloads and examples REDHAT Application Server and Examples Copyright 2004 Kanti Prasad All rights reserved

93 Copyright 2004 Kanti Prasad All rights reserved
Sans Serif fonts are the easiest to read especially from a distance and for titles and headings. Make sure your text can be read from a distance Long titles can confuse. Try to avoid them. These sizes are easy on the eye. Common practice punctuation can be confusing and distracting on screen. Remember, you are not writing a book. DON’T use too many styles for the same reason as not using too many animations. Only use jargon etc when you know your audience will understand without explanation. Copyright 2004 Kanti Prasad All rights reserved


Download ppt "A Practical Introduction to Enterprise Java Beans"

Similar presentations


Ads by Google