A Practical Introduction to Enterprise Java Beans A
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 J 2 EE BY YOU DOWNLOADED THIS PRESENTATIOIN FROM http: //www. javafaq. nu Copyright 2004 Kanti Prasad All rights reserved Kantimahanti Prasad Kanti. Prasad@pramerica. ie or Kanti 1@donegal. net
1. Learning objectives 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. Component Technology characteristics Standard Infrastructure needs Application Servers Containers J 2 EE 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 Copyright 2004 Kanti Prasad All rights reserved A STAR or a different color represents important points to NOTE
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 Ph. D 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. U NEVER FAIL TILL U QUIT 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 3 rd party tested Temperament Sorter results are below https: //www. advisorteam. com/temperament_sorter/testresult. asp? TID=740281673499&PID=15800 https: //www. advisorteam. com/temperament_sorter/testresultc. asp? TID=740281662156&PID=13606 If you liked his presentation, tell others and if you have a comment, tell him. He can be reached at Kanti. Prasad@Pramerica. ie or Kanti 1@donegal. net
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, Charles. Johnson & 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 ARUNA SUNAYANA SADHGI his Parents Dr. Rao & Family DEDICATED TO Copyright 2004 Kanti Prasad All rights reserved his Brothers his Sisters & his Cousins
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 Copyright 2004 Kanti Prasad All rights reserved
5. Component Characteristics Components Characteristics include l Properties l Reusability l Operations l Shareable l Events l Distributable l Deployable l Self Containment l Self description Copyright 2004 Kanti Prasad All rights reserved
6. Component P O E Components should have a mechanism for exporting l Properties l Operations l Events Copyright 2004 Kanti Prasad All rights reserved
7. Deployable Components are operation independent of • • Hardware The underlying operating system Their Application Server The network protocol they use Copyright 2004 Kanti Prasad All rights reserved
8. Reusable Components Component services can be used as a part of business logic of other components Copyright 2004 Kanti Prasad All rights reserved YOU DOWNLOADED THIS PRESENTATIOIN FROM http: //www. javafaq. nu
9. Shareable Components If multiple clients are using a component simultaneously, the component will provide the same quality of service to all the clients Copyright 2004 Kanti Prasad All rights reserved
10. Distributable Components should provide services to clients running locally or remotely EJB Container EJB Possible Remote CLIENTS Local CLIENTS Remote CLIENTS Copyright 2004 Kanti Prasad All rights reserved
11. Self. Contained Components should only contain the code necessary to implement their services Infrastructure services should be injected by the execution environment Copyright 2004 Kanti Prasad All rights reserved
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 Copyright 2004 Kanti Prasad All rights reserved
13. Applicatoin Servers An application server provides the infrastructure and services to run components/applications Application Server products are mostly J 2 EE based solutions Copyright 2004 Kanti Prasad All rights reserved Non-J 2 EE solutions (PHP, Cold Fusion, Perl, etc. ) Microsoft Solutions (COM, ASP. Net VB. Net, C# etc. )
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 EJB Pool CLIENT Network CLIENT Copyright 2004 Kanti Prasad All rights reserved EJB EJB DB
15. Directory of Application Servers provide clients access to software or other applications that run only on the server Examples include web servers, e-mail 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 http: //www. devx. com/enterprise/html/16268 http: //www. javacommerce. com/articles/serverlist. htm Copyright 2004 Kanti Prasad All rights reserved
16. Container means a pre developed Software A Container : Fish cannot survive outside water & EJB’s cannot survive outside containers • • • provides the environment in which a bean executes generates Home Object generates EJB Object Implicit Middleware • manages individual bean instances & To increase capability. clustering is taken care by the vendor Transaction gained through declaration Container provides System services like Persistence Security Connection Pooling Threading App Server EJB Container EJB STUB CLIENT Network Container intercepts requests EJB Container knows what to do, as you describe everything in a special descriptor file Copyright 2004 Kanti Prasad All rights reserved
17. J 2 EE Overview Deployment Descriptors (DDs) Web Server Independence Application Server Independence Database Independence Enterprise Resource Management Services Distributed Communication Services Common Programming Services Operating System Independence Hardware Independence Copyright 2004 Kanti Prasad All rights reserved Enterprise Components services standards component-based J 2 EE Container/Server J 2 EE Interfaces Management Services Deployment/Configuration J 2 SE Language/Interfaces J 2 SE Runtime Operating System Platform Hardware Platform Deploy Tools Data
18. J 2 EE 1. 4 APIs J 2 EE defines a model for developing multi-tier, web based, enterprise applications with distributed components Applet Container HTTP/S Applet J 2 SE Web Container JSP Application Client Container HTTP/S X C B S R C S JAF JMX A D N B I C EJB JAX- J J RPC A A X C SAAJ R C W J E M B S S J 2 SE Client RMI/ IIOP Java Mgmt J J J C N D Mail T O JAF 4 TIER EIS DAO DB 2 TIER J 2 SE Main. Frames For all the APIs refer http: //java. sun. com/j 2 ee/1. 4/docs/tutorial/doc/index. html Copyright 2004 Kanti Prasad All rights reserved JMX A D N B I C J 2 SE 3 TIER JAX- J W Mgmt J J C RPC A E D M O X B JMX B SAAJ S N R S C EJB Container Servlet JSP Servlet ENGINE JAX- J J W J Java Mgmt J J J C RPC A A E M Mail N D T O SAAJ RMI/ IIOP
19. Enterprise Java. Beans Model EJB is Sun’s J 2 EE 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 Enterprise. 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 Copyright 2004 Kanti Prasad All rights reserved != Java Beans 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
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 EJB Client Process EJB Client Home create remove find Remote invoke Copyright 2004 Kanti Prasad All rights reserved Network Local. Home Local create remove find STUB invoke STUB EJB Impl create timeout remove passivate activate find load invoke store Delegate EJB Pool J 2 EE EJB Container/Server
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 Copyright 2004 Kanti Prasad All rights reserved YOU DOWNLOADED THIS PRESENTATIOIN FROM http: //www. javafaq. nu
22. Java Naming and Directory Interface (JNDI) 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. Initial. Context is the entry point to the EJB Server • bind – associates a name with an object • lookup – finds an object given the name 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 Copyright 2004 Kanti Prasad All rights reserved
24. EJB Roles Service & Tool Provider provides Server, Container and integrates with distributed facilities EJB Provider Application Assembler creates EJB components assembles apps from per-built EJB comp Deployment Specialist deploys apps and understands architecture issues builds application supplies tools Tools Provider Application Assembler develops EJB Provider Copyright 2004 Kanti Prasad All rights reserved deploys system Deployer supplies Application Server Provider System Administrator maintains deployment
25. EJB Design Approaches EJB model is based on three basic design approaches for building distributed component systems Stateless server approach Persistent Object approach Session-oriented approach The EJB specification provides these as Stateless session Beans Stateful session Beans All Entity. Beans implements Interface javax. ejb. Entity. Bean extends Implementing one of these interfaces indicates your JAVA class is an EJB. Message driven beans Entity Beans All Session. Beans implements All Message. Driven. Beans Interface javax. ejb. Session. Bean implements Interface javax. ejb. Message. Driven. Bean extends javax. ejb. Enterprise. Bean interface extends It is only a marker Interface java. io. Serializable and there are no methods to Implement. Serialization is the reason EJB is distributable. Copyright 2004 Kanti Prasad All rights reserved As all these are extending the two Interfaces hence they have the behavior of both the Interfaces.
26. EJB Architecture Naming Service such as LDAP Naming 2 Transaction Persistence. Server Security A SERVICES H Server B App Server H JNDI Initial Context H 3 1 H Home Obj Stub Application Client EJB Obj Stub EJB Container 8 Home Interface 4 Home Object (FACTORY) 10 5 creates 6 RMI/IIOP Remote Interface 7 EJB Object (Wrapper) EIS EJB DB (Business Logic Class) 9 Main. Frames delegates request 11 Container implements/autogenerates code for the Interfaces we have written We will write only this Container manages TRANSACTIONS, PERSISTENCE, SECURITY & POOLING Copyright 2004 Kanti Prasad All rights reserved
27. EJB Flow Chart C Start ask JNDI Server for the Home Object 1 JNDI Server returns ref of Home Stub 2 ask Home for the EJB Object 4 returns reference of Remote Stub 5 Copyright 2004 Kanti Prasad All rights reserved invokes a business method thru Remote Stub 7 goes to the JNDI Server and gets the EJB Object 8 Remote Interface then wraps a request to the Bean class 3 creates EJB Object C 6 9 Clients receives the required info End
28. Client View of EJB ENTITY BEANS are like NOUNS as they represent data or data related logic. App Server EJB Container EJB Home or EJB Local Home Application Client RMI/ IIOP EJB Object or EJB Local Object JMS Destination e. g • Bank teller • Credit Card authorization Session Bean instance Entity Bean instance e. g • Bank account balance • Purchase order Message Driven Bean instance e. g • Stock trade messages • Work flow messages SESSION BEANS are like VERBS as they represent action or business process related logic. MESSAGE DRIVEN BEANS have message oriented logic. Copyright 2004 Kanti Prasad All rights reserved 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.
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 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 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 Copyright 2004 Kanti Prasad All rights reserved YOU DOWNLOADED THIS PRESENTATIOIN FROM http: //www. javafaq. nu
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 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 Session. Context and • • • retrieves home interfaces gets and sets transactions attributes obtains security attribute The set. Session. Context method is used to inform the bean about the session context 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 Copyright 2004 Kanti Prasad All rights reserved
35. Stateless Session EJBs View Stateless Session EJB Client Local. Home Local Client Process EJB Client Home Remote Logic input Network EJB Pool output J 2 EE EJB Container/Server 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
36. Life Cycle of Stateless Session Bean Each method call is an invocation from the container to the Bean Container decided it needs more instances in the pool to service clients Bean Instance does not exiist Class. new. Instance() set. Session. Context() ejb. Remove() ejb. Create() Pool of equivalent method ready instances Client called another Transactional business method on the EJB Object. Transactional Business Method Client called remove() on the EJB object (or the client times out)
37. Stateful Session EJBs View Stateful Session EJB Client Local. Home Local Client Process EJB Client Home Remote Logic State input Network EJB Pool output J 2 EE EJB Container/Server 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
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. new. Instance() set. Session. Context() Client called a non-transactional business method on the EJBObject Bean instance is ready to service method calls ejb. Passivate() ejb. Activate() Client called a transactional business method on the EJB Object before. Completion() after. Begin() Client called another Transactional business method on the EJB Object. Client times out ejb. Create(args) Non-Transactional Business Method If transaction ended in a commit. . ejb. Remove() Container’s limit of instantiated beans are reached, so it must swap your bean out. after. Completion(true) Bean instance is within a transaction and ready to service method calls after. Completion(false) Client called a method on a passivated bean, so Container must swap your Bean back in We need to write all the methods that are there in the Transactional Business Method Bean instance is in the passive state Implemented class If we implement Javax. ejb. Session. Synchronization then we need to write these methods. If transaction ended in an abort.
39. Stateful vs Stateless Stateful Bean Stateless Bean A stateful bean contains a conversational state that is retained across method calls and transactions. A stateless bean does not have any state between calls to its methods. 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 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. Method by method comparison can be seen in EJB 20 Matrix. doc at http: //www. volantec. biz/cmp 20. htm Copyright 2004 Kanti Prasad All rights reserved
40. 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. Copyright 2004 Kanti Prasad All rights reserved
41. BMP Entity EJBs (BMP = Bean-Managed Persistence) Entity Bean (BMP) EJB Client Local. Home Local Client Process EJB Client Hand Coded Logic Home Remote Network EJB Pool input output J 2 EE EJB Container/Server Persisted objects (via hand-coding) data 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
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 hash. Code() and equals(. . ) methods does not implement java. rmi. remote 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 App Server EJB Container CLIENT EJB Network CLIENT Copyright 2004 Kanti Prasad All rights reserved EJB DB
44. Life Cycle of BMP Entity Bean Each method call is an Invocation from the container to the Bean Container decided it needs another Entity Bean insinstance new. Instance() unset. Entity. Context() JVM will garbage collectt and call finalize() set. Entity. Context() Client called instance independent ejb. Home() Business method Client called a finder Method on the home interface ejb. Home() Client called create() on the home interface (this will Create new database data) Container determined that the database is out of synch with the bean. The Bean needs to load the new Database data. ejb. Find() Pooled Activates the Bean Passivates the Bean ejb. Create() ejb. Activate() ejb. Store() ejb. Post. Create() ejb. Load() ejb. Passivate() ejb. Load() Client called a business method on a EJBObject Container decided it doesn’t need the Entity Bean instance anymore Does not exiist Ready Business Method ejb. Remove() ejb. Store() Client called remove() on the EJB object (this will destroy Database data) Container determined that the database is out of synch with the bean. The Bean needs to store its Data into the Database
45. CMP Entity EJBs (CMP = Container-Managed Persistence) Entity Bean (CMP) EJB Client Local. Home Local Client Process EJB Client Generated Logic Home Remote Network EJB Pool input output J 2 EE EJB Container/Server Persisted objects (via container services) data Persistence DDs 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
46. Life Cycle of CMP Entity Bean Each method call is an Invocation from the container to the Bean NOTE : BMP has no ejb. Select() Container decided it needs another Entity Bean in new. Instance() unset. Entity. Context() JVM will garbage collectt and call finalize() set. Entity. Context() Client called instance independent ejb. Home() Business method ejb. Home() Client called create() on the home interface (this will create new database data) Container determined that the database is out of Synch with the bean. The Bean needs to load the new Database data. Client called a finder method on the home Interface, or bean called its own ejb. Select() method to locate Database data ejb. Find() or ejb. Select() Pooled Activates the Bean Passivates the Bean ejb. Create() ejb. Activate() ejb. Store() ejb. Post. Create() ejb. Load() ejb. Passivate() ejb. Load() Client called a business method on a EJBObject Container decided it doesn’t need the Entity Bean instance anymore does not exiist Ready Business Method Or ejb. Select() ejb. Remove() ejb. Store() Client called remove() on the EJB object (this will destroy Database data) Container determined that the database is out of Synch with the bean. The Bean needs to store its Data into the Database
47. BMP vs CMP Bean Managed Persistance Container Managed Persistance BMP offers a tactical approach CMP is more strategic The developer takes care of handling persistence Vendor takes care of everything by using O-R or OODB mappings using metadata. BMP uses hard coded queries so we can optimize our queries 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 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 Method by method comparison can be seen in EJB 20 Matrix. doc at http: //www. volantec. biz/cmp 20. htm 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 on. Message() is executed • does not survive EJB server crashes • provides a single-use service • is relatively short lived • is only a bean class – no interfaces Copyright 2004 Kanti Prasad All rights reserved
49. Message Driven EJBs Producer Process Message Messaging API Producer Messaging Service Message Network Message-Driven Bean Message Queue Handler Logic input Message Listener EJB Pool J 2 EE EJB Container/Server 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
50. Life Cycle of Message Driven Bean Each method call is an Invocation from the container to the Bean Container decided it needs another Message Driven. Bean Instance Does not exiist new. Instance() ejb. Remove() set. Message. Driven. Context() ejb. Create() Pooled on. Message()
51. 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 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 Life. Cycle Management, Persistence, Transaction and Security. Copyright 2004 Kanti Prasad All rights reserved
52. Other interfaces and classes § § Local interfaces are used for access within server context § javax. ejb. EJBLocal. Home § javax. ejb. EJBLocal. Object Interfaces for serializing EJB references § § § E. g. : • Inter component calls • Servlet invocation Home. Handle - reference to EJBHome Handle - reference to EJBObject EJBMeta. Data 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 Copyright 2004 Kanti Prasad All rights reserved
53. Exceptions § § System exceptions are unchecked and propagated to the client as java. rmi. Remote. Exception Application exceptions are checked and propagated to the client as a descendant of java. lang. Exception § EJB-specific exceptions include Finder. Exception, Create. Exception, Remote. Exception (all in javax. ejb package) § Business method exceptions are at the discretion of the EJB developer Copyright 2004 Kanti Prasad All rights reserved
YOU DOWNLOADED THIS PRESENTATIOIN FROM http: //www. javafaq. nu EXAMPLE 1 STATELESS BEAN Copyright 2004 Kanti Prasad All rights reserved
54. Steps to Develop an EJB C Start Write. java files for the BEAN, HOME and REMOTE interfaces Write the Deployment descriptor Compile all the STEP 1 files into. class files Using the Jar utility create an EJB Jar file containing STEP 2 & STEP 3 files C 1 5 2 Configure your EJB Server. E. g DB connections thread pooling etc Then copy the EJB Jar file Start your EJB container and 6 confirm that it has loaded the EJB Jar file. 3 Connect to your EJB by writing a test 7 Client. java file compile it and run it. 4 End 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
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. Enterprise. Bean Javax. ejb. EJBObject Javax. ejb. EJBHome Javax. ejb. Sesson. Bean Supplied by the Bean Provider / Developer/ We will write ! We Hello world Remote Interface need to CODE only Interface this block Hello World Home Generated for us by the Container verdor’s tools Hello world EJB Object Copyright 2004 Kanti Prasad All rights reserved Hello World Home Object Hello World Bean Implementation Class 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.
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. Enterprise. Bean Javax. ejb. EJBLocal. Object Javax. ejb. EJBLocal. Home Javax. ejb. Sesson. Bean Supplied by the Bean Provider / Developer/ We will write ! Hello world Local. Interface. We need Hello to World Local Home CODE only this. Interface block Generated for us by the Container verdor’s tools Hello world EJB Local. Object Copyright 2004 Kanti Prasad All rights reserved Hello World Local Home Object Hello World Bean Implementation Class 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.
57. Hello. Bean 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 (Hello. Bean). Rules of Java says package declaration should be at the beginning and ends with a semi colon package examples ; import java. io. Serializable; import java. rmi. Remote. Exception; Importing the required files import javax. ejb. Create. Exception; import javax. ejb. EJBHome; public interface Hello. Home extends javax. ejb. EJBHome Our interface Hello. Home is extending EJBHome means it has all the behaviour of EJBHome { Hello create() throws java. rmi. Remote. Exception, javax. ejb. Create. Exception; Interface methods should end with a semicolon ; This method creates/manufactures the EJBObject and returns it. This create() method corresponds to the ejb. Create() method in Hello. Bean. As for every Interface we need implementation, Note so Container will implement code) for Remote this Home Interface we are(autogenerate throwing 2 exceptions and. Interface Create. for us, which is the EJBHome Objec } 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
58. Hello. Local. Home Interface So now lets code the Hello. Local. Home Interface This is the Local. Home Interface for the Home EJB (Hello. Bean). package examples ; Rules of Java says package declaration should be at the beginning and ends with a semi colon import javax. ejb. EJBLocal. Home; import javax. ejb. Create. Exception; import javax. ejb. Finder. Exception; import java. util. Collection; Our interface Hello. Local. Home is extending EJBLocal. Home means it has all the behaviour of EJBLocal. Home public interface Hello. Local. Home extends javax. ejb. EJBLocal. Home { Hello. Local create() throws javax. ejb. Create. Exception; This methodso creates/manufactures the EJBLocal Objectcode) and returns. This. Home create() corresponds to the As for every Interface we need implementation, Container will implement (autogenerate for thisitmethods Local for method us, isa the Local. Home Interface should endwhich with semicolon ; Object ejb. Create() method in Hello. Bean. Note Local. Home Interface we are throwing Create and not Remote there is no network NOTE : Rules of In Interfaces states that there should be only no implementation so you exception will find as only method signatures. } Copyright 2004 Kanti Prasad All rights reserved
59. Hello. Bean 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 ; Rules of Java says package declaration should be at the beginning and ends with a semi colon import java. util. *; Importing the required files import javax. ejb. EJBObject; import java. rmi. Remote. Exception; public interface Hello extends javax. ejb. EJBObject Our interface Hello is extending EJBObject means it has all the behaviour of EJBObject { public String hello() throws java. rmi. Remote. Exception; As our requirement wants a business logic to greet Hello World a single method would be sufficient. } Interface methods should end with a semicolon ; 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 Remote. Exception so we are throwing it. 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
60. Hello. Local Interface Clients interact with the EJB Object through this Local interface when there is no network involved. . package examples ; Rules of Java says package declaration should be at the beginning and ends with a semi colon import javax. ejb. EJBLocal. Object; public interface Hello. Local extends javax. ejb. EJBLocal. Object Our interface Hello is extending EJBLocal. Object means it has all the behaviour of EJBLocal. Object { Interface methods should end with a semicolon ; public String hello() ; 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 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
61. The Bean Class So now lets code the actual EJB Class This is where we will code our Business logic package examples ; Rules of Java says package declaration should be at the beginning and ends with a semi colon import java. util. *; Importing the required files import javax. ejb. *; public class Hello. Bean implements javax. ejb. Session. Bean NOTE : Note If it is: Entity this is. Bean a class we and will not implement an Interface javax. ejb. Entity. Bean like the other two and(Home if it is Message / Remote). driven This is bean implementing we will implement Session. Bean javax. ejb. Messagedriven. Bean 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. Session. Bean. { private Session. Context This ctx; ejb. Create() corresponds to the Homeobject Create(). NOTE : in Stateless Bean no arguments are sent public void ejb. Create() { System. out. println(“ejb. Create()”); } much to clean up. public void ejb. Remove() { System. out. println(“ejb. Remove()”); } There is nothing These are called Management or In Statelss Bean ejb. Activate public void ejb. Activate() { System. out. println(“ejb. Activate()”); } Call back methods and ejb. Passivate Do not apply public void ejb. Passivate() { System. out. println(“ejb. Passivate()”); } public void set. Session. Context(javax. ejb. Session. Context ctx) { Storing the Context in a variable so that it can be queried later. this. ctx = ctx; } NOTE : Because it is a Session Bean we are using set. Session. Context for Entity Bean we use set. Entity. Context and for Message Driven Bean we use set. Message. Driven. Context. public String hello() { System. out. println(“Hello()”); return “Hello World! “ ; } 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 Copyright 2004 Kanti Prasad All rights reserved 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.
62. The Deployment descriptor So now lets complete our EJB by writing the deployment descriptor. THERE ARE MANY TOOLS WHICH CREATES THE DESCRIPTOR FOR US As a Bean provider we need to specify the Middleware needs through this descriptor. <!DOCTYPE ejb-jar PUBLIC “-//Sun Microsystems, Inc. // DTD Enterprise Java. Beans 2. 0 // EN “ “ http: //java. sun. com. dtd/ejb-jar_2_0. dtd”> XML Standard requirement <ejb-jar> <enterprise-beans> <session> The nickname for this particular Bean <ejb-name> Hello </ejb-name> <home>examples. Hello. Home</home> The fully qualified name of the Home Interface <remote>examples. Hello</remote> The fully qualified name of the Remote Interface <local-home>examples. Hello. Local. Home</local-home> The fully qualified name of the Local Home. Interface <local>examples. Hello. Local</local> The fully qualified name of the Local Interface <ejb-class>examples. Hello. Bean</ejb-class> The fully qualified name of the EJB Class <session-type>Stateless</session-type> Whether the session bean is stateful or stateless <transaction-type>Container</transaction-type> </session> </enterprise-beans> </ejb-jar> Copyright 2004 Kanti Prasad All rights reserved
63. The Client So now lets code our Client to access our simple stateless session bean. package examples; Rules of Java says package declaration should be at the beginning and ends with a semi colon import javax. naming. Context; importing the necessary files import javax. naming. Initial. Context; import java. util. Properties; As there is static key word this main method executes first before any other method in that class public class Hello. Client { public static void main(String [] args) throws Exception{ Properties props = System. get. Properties(); Assigning props variable with properties information for JNDI initialization Context ctx = new Initial. Context(props); 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 a reference to the Home Object obj = ctx. lookup(“Hello. Home”); Get location of the server etc. Object- the factory for Hello EJB Objects. Hello. Home home = (Hello. Home) javax. rmi. Portable. Remote. Object. narrow( obj, Hello. Home. class); Use the factory to create the Hello EJB Object. We are then calling the hello() method Hello hello = home. create(); We are casting Hello. Home here, as Home Objects are RMI-IIOP objects and so we On the EJB Object. The EJB object will delegate the call to the Bean, receive the Need to use a special RMI-IIOP cast. Results and return it to us. We then print it on the screen. System. out. println(hello()); hello. remove(); }} Once we are done with the EJB Object, we can remove it. Copyright 2004 Kanti Prasad All rights reserved NOTE : To call Local Interface you need not cast with the Portable. Remote. Object. So the block in red will be changed to Object obj = ctx. lookup(“java: comp/env/Hello. Local. Home”); ( to get a ref to Local. Home Object) Hello. Local. Home home = (Hello. Local. Home)obj;
64. EJB Jar File The folder structure within the Ejb-jar file is META-INF/MANIFEST. MF META-INF/ejb-jar. xml examples/Hello. Bean. class examples/Hello. Local. Home. class examples/Hello. Local. class examples/Hello. class Properties File Remote/Local Interface Home. Local. Home Interface Enterprise Bean Class Deployment Descriptor Jar Manifest Jar Creator Jar file DEPLOYED Or manually run C: >Jar cf Hello. World. 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
65. EJB Application Assembler Jar file . JAR ARC HIEVE (. jar) EJB-JAR. XML REMOTE HOME EJB Copyright 2004 Kanti Prasad All rights reserved Deployment Descriptor . WAR Deployment Tool WEB ARCHIEVE (. war) WEB. XML Enterprise Archive (. EAR Files) (Application. XML) HTML JSP Servlets
YOU DOWNLOADED THIS PRESENTATIOIN FROM http: //www. javafaq. nu EXAMPLE 2 STATEFUL BEAN Copyright 2004 Kanti Prasad All rights reserved
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. Remote. Exception; import samples. ejb. stateful. simple. tools. Book. Exception; Importing the required classes Remote Cart is extending EJBObject means Cart has all the behaviour of it public interface Cart extends EJBObject Our bean class Cart. Bean methods are mirrored here { public void add. Book(String title) throws Remote. Exception; public void remove. Book(String title) throws Book. Exception, Remote. Exception; public Vector get. Contents() throws Remote. Exception; } 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
Stateful Session Home Interface package declaration should be in the beginning package samples. ejb. stateful. simple. ejb; import java. io. Serializable; import java. rmi. Remote. Exception; import javax. ejb. Create. Exception; import javax. ejb. EJBHome; Importing the required classes Cart. Home is extending EJBHome means Cart. Home has all the behaviour of it public interface Cart. Home extends EJBHome { In a Stateful Bean you can have more than one create method taking arguments Cart create(String person) throws Remote. Exception, Create. Exception; In our bean class Cart. Bean these represent ejb. Create(String person) & ejb. Create(String person, String id) Cart create(String person, String id) throws Remote. Exception, Create. Exception; } 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
Stateful Session Bean Class package samples. ejb. stateful. simple. ejb; package declaration should be in the beginning import java. util. *; import javax. ejb. *; import samples. ejb. stateful. simple. tools. Book. Exception; import samples. ejb. stateful. simple. tools. Id. Verifier; Importing the required classes public class Cart. Bean implements Session. Bean { Cart. Bean Class is implementing sessionbean means this bean class is a session bean String customer. Name; String customer. Id; Vector contents; We defined. This this also method in the Cart interface. represents the remote Home create(String person) method public void ejb. Create(String person) throws Create. Exception { if (person == null) { throw new Create. Exception("Null person not allowed. "); } else { customer. Name = person; } customer. Id = "0"; contents = new Vector(); 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
Stateful Session Bean Class public void ejb. Create(String person, String id) throws Create. Exception { if (person == null) { This also Werepresents defined this the Cart remote interface themethod Home in create(String person, String throw new Create. Exception("Null person not allowed. "); } else { customer. Name = person; } id) method we defined The new operator is instantiating the instance of a class Id. Verifier id. Checker = new Id. Verifier(); if (id. Checker. validate(id)) { customer. Id = id; We are calling the validate(id) } else { throw new Create. Exception("Invalid id: " + id); } method from the class ID Verifier // This block is a supporting business method written in id. Verifier class contents = new Vector(); } We defined this method in the Cart remote interface public void add. Book(String title) { contents. add. Element(title); } We defined this method in the Cart remote interface public void remove. Book(String title) throws Book. Exception { boolean result = contents. remove. Element(title); We defined contents as if (result == false) { throw new Book. Exception(title + " not in cart. "); } } Copyright 2004 Kanti Prasad All rights reserved a vector
Stateful Session Bean Class We defined this method in the Cart remote interface public Vector get. Contents() { return contents; } public Cart. Bean() {} public void ejb. Remove() {} Bean class constructor We need to write these methods as we are implementing Session. Bean public void ejb. Activate() {} public void ejb. Passivate() {} public void set. Session. Context(Session. Context sc) {} } Rules of implement states we need to implement all methods that are there in the implemented interface Copyright 2004 Kanti Prasad All rights reserved
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="http: //java. sun. com/xml/ns/j 2 ee" xmlns: xsi="http: //www. w 3. org/2001/XMLSchemainstance" xsi: schema. Location="http: //java. sun. com/xml/ns/j 2 ee/ejb-jar_2_1. xsd"> <display-name>Cart. JAR</display-name> required by any XML document <enterprise-beans> <session> <display-name>Cart. EJB</display-name> The nickname for this particular Bean <ejb-name>Cart. EJB</ejb-name> <home>samples. ejb. stateful. simple. ejb. Cart. Home</home> The fully qualified name of the Home Interface <remote>samples. ejb. stateful. simple. ejb. Cart</remote> The fully qualified name of the Remote Interface <ejb-class>samples. ejb. stateful. simple. ejb. Cart. Bean</ejb-class> The fully qualified name of the EJB Class <session-type>Stateful</session-type> Bean type is mentioned here <transaction-type>Container</transaction-type> <security-identity> <use-caller-identity/> </security-identity> </session> Closing session and ejb </enterprise-beans> Copyright 2004 Kanti Prasad All rights reserved
Stateful Deployment Descriptor <assembly-descriptor> <container-transaction> <method> <ejb-name>Cart. EJB</ejb-name> <method-intf>Remote</method-intf> <method-name>get. Contents</method-name> </method> <trans-attribute>Required</trans-attribute> </container-transaction> <method> <ejb-name>Cart. EJB</ejb-name> <method-intf>Remote</method-intf> <method-name>remove. Book</method-name> <method-params> <method-param>java. lang. String</method-param> </method-params> </method> <trans-attribute>Not. Supported</trans-attribute> </container-transaction> Copyright 2004 Kanti Prasad All rights reserved Passing Bean class methods and parameter info
Stateful Deployment Descriptor <container-transaction> <method> <ejb-name>Cart. EJB</ejb-name> <method-intf>Remote</method-intf> <method-name>add. Book</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> Copyright 2004 Kanti Prasad All rights reserved Passing Bean class methods and parameter info
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. Initial. Context; import javax. rmi. Portable. Remote. Object; public class Cart. Client { Importing the required classes Client class public static void main(String[] args) { As static is there this main method will execute first try { The new operator is instantiating the instance of Context initial = new Initial. Context(); Object objref = initial. lookup("java: comp/env/ejb/Simple. Cart"); a class Looking into JNDI Cart. Home home = (Cart. Home)Portable. Remote. Object. narrow(objref, Cart. Home. class); Casting with a suitable RMI IIOP object Creating the object Cart shopping. Cart = home. create("Duke De. Earl", "123"); shopping. Cart. add. Book("The Martian Chronicles"); adding books to the object shopping. Cart. add. Book("2001 A Space Odyssey"); shopping. Cart. add. Book("The Left Hand of Darkness"); Vector book. List = new Vector(); book. List = shopping. Cart. get. Contents(); Copyright 2004 Kanti Prasad All rights reserved Invoking the bean class method through remote interface Cart
Stateful Session Client We defined booklist as a vector Enumeration enumer = book. List. elements(); while (enumer. has. More. Elements()) { String title = (String) enumer. next. Element(); System. out. println(title); } After storing in the variable “title” we are printing it shopping. Cart. remove. Book("Alice in Wonderland"); shopping. Cart. remove(); Removing a particular book System. exit(0); using the bean class method remove. Book through remote interface Cart –as we defined it this way Cart shopping. Cart = home. create("Duke De. Earl", "123"); } catch (Book. Exception ex) { System. err. println("Caught a Book. Exception: " + ex. get. Message()); System. exit(0); We had written a new class Book. Exception } catch (Exception ex) { System. err. println("Caught an unexpected exception!"); ex. print. Stack. Trace(); System. exit(1); } } } Copyright 2004 Kanti Prasad All rights reserved and using its method to catch any errors
Book Exception package samples. ejb. stateful. simple. tools; public class Book. Exception extends Exception { /** * Default constructor. */ public Book. Exception() { } /** * Constructor with a <code>String<code> as a parameter. * @param msg message, describing the exception. */ public Book. Exception(String msg) { super(msg); } } Copyright 2004 Kanti Prasad All rights reserved
ID Verifier package samples. ejb. stateful. simple. tools; public class Id. Verifier { /** * Default constructor. */ public Id. Verifier() { } public boolean validate(String id) { boolean result = true; for (int i = 0; i < id. length(); i++) { if (Character. is. Digit(id. char. At(i)) == false) result = false; } return result; } } Copyright 2004 Kanti Prasad All rights reserved
YOU DOWNLOADED THIS PRESENTATIOIN FROM http: //www. javafaq. nu ALL EXAMPLES CAN BE SEEN AT http: //www. weblogic. com/docs/examples/ejb/Package-examples. ejb. html http: //my. execpc. com/~gopalan/java/entity. html http: //java. sun. com/developer/online. Training/Beans/EJBTutorial/ http: //developers. sun. com/prodtech/javatools/jsstandard/reference/techart/entitybeans. html Copyright 2004 Kanti Prasad All rights reserved
66. Component Comparison Component Distributability EJB Can implement the Remote or Local Interface Active. X 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 Copyright 2004 Kanti Prasad All rights reserved
67. Component Comparison Components provide interfaces in the form of Operations EJB exports operations through Remote Interface Active. X exports operations in the same interface CORBA exports methods through Interface Repository Copyright 2004 Kanti Prasad All rights reserved
68. 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 Active. X 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 CORBAServices have different APIs. CORBAServices can be complicated to code with. CORBAServices are not supported by all ORBs Copyright 2004 Kanti Prasad All rights reserved
69. Component Comparison Components provide interfaces in the form of Properties. EJB Properties are not explicitly exported but can be mimicked through accessor operations Active. X exports Properties in the same interface CORBA Properties not explicitly exported but can be mimicked through attributes Copyright 2004 Kanti Prasad All rights reserved
70. Component Comparison Components provide interfaces in the form of Events. EJB Events supported through JMS with Message Driven Bean Active. X exports Events in the same interface CORBA Events supported through Event Service but cannot be exported Copyright 2004 Kanti Prasad All rights reserved
71. 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 Copyright 2004 Kanti Prasad All rights reserved
72. Component Comparison Component Reusability Active X Incorporating the contents of an Active. X can be done in two ways: • • by having the new Active. X use the services of an old Active. X as a client or by Delegation The Components being reused must be registered on the development machine Copyright 2004 Kanti Prasad All rights reserved
73. 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 Copyright 2004 Kanti Prasad All rights reserved
74. 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. Active. X uses Microsoft's in–process/out-of-process architecture for sharing multiple Active. X 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. Copyright 2004 Kanti Prasad All rights reserved
75. Conclusion 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 Local. Interfaces were introduced. We disected the EJB and went deeper into each part i. e. BEAN Class, Remote Interface, EJB 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 100 s’ of Application servers but in this presentation you can see a few majorly used App. Servers sample implementation web links. Just download any one of them and try out for yourself. YOU DOWNLOADED THIS PRESENTATIOIN FROM http: //www. javafaq. nu CONGRATULATIONS! Now you know as much as he know of EJB Copyright 2004 Kanti Prasad All rights reserved If you have any comments or appreciations then please email him at Kanti 1@donegal. net, Kanti. Prasad@donegal. net He likes to hear your feed back!
76. References Application Server Information , EJB Documentation & Tutorials are found here Notes on Deploying on different Application Servers. The Art of EJB Deployment http: //www. javaworld. com/javaworld/jw-08 -2001/jw-0803 -ejb. html Most of EJB’s related information can be seen at http: //www. volantec. biz/ejb. htm http: //www. theserverside. com/ Mastering Enterprise Java Beans by Ed Roman , Scott Ambler & Tyler Jewel. EJB Documentation http: //java. sun. com/products/ejb/javadoc-2_0 -fr/ http: //my. execpc. com/~gopalan/java_tutorial. html Application Servers download information. Most of them are either free or have a 60 day trial version For JBOSS Open Source go to http: //www. jboss. org/downloads/index http: //www. kevinboone. com/jboss_tut_1. html SUN’s downloads and examples http: //developers. sun. com/prodtech/javatools/jsstandard/reference/docs/s 1 s 5/partsuppliers. html http: //java. sun. com/j 2 se/1. 4. 2/download. html , http: //java. sun. com/j 2 ee/1. 4/docs/tutorial/doc/ http: //java. sun. com/developer/online. Training/EJBIntro. html BEA Web. Logic downloads and examples http: //commerce. bea. com/index. jsp , http: //www. weblogic. com/docs/examples/index. html http: //dev 2 dev. bea. com/codelibrary/code/examples_ejb 20. jsp Web. Sphere downloads and examples http: //www-306. ibm. com/software/webservers/appserv/doc/v 20 dcadv/doc/howto/ep 001. html REDHAT Application Server and Examples http: //www. redhat. com/docs/manuals/rhaps/jonas-guide/ Copyright 2004 Kanti Prasad All rights reserved Covers 90 % of the MARKET
Copyright 2004 Kanti Prasad All rights reserved
- Slides: 93