Enterprise Java BeansSlide 2InterpositionSlide 4Server-Side ImplicationsManaged: EJB Container ServicesEJB TypesSlide 8Entity BeansSession BeansMessage-Driven BeansSlide 12Slide 13Before working with EJB’sSlide 15Naming ConceptsNaming ConventionsBindingsSlide 19ContextNaming SystemDirectory ServiceReverse lookup or content-based searchingDirectory Enabled ApplicationsJava Naming and Directory Interface JNDIJava Naming and Directory Interface (JNDI)JNDISlide 28Namespaces are represented by the Context InterfaceThe Context InterfaceLookUp.javaSlide 32Slide 33Slide 34ListCurrentDirectory.javaSlide 36Slide 37Slide 38Slide 39Slide 40Slide 41Back to EJBImplementing Entity and Session BeansSlide 44Slide 45For Entity BeansImplementing a Message-Driven BeanSlide 48In both modelsPoint-to-point On the client sidePoint-To-Point On the server side95-702 Organizational Communication Technologies1Enterprise Java BeansOverview95-702 Organizational Communication Technologies2Notes from: “Advanced Java 2 Platform How to Program” Deitel Deitel Santry “Thinking in Enterprise Java” Bruce Eckel et. Al. Sun downloadable documentation EJB 2.1 API http://java.sun.com/webapps/download/Display95-702 Organizational Communication Technologies3InterpositionApplicationstub skeleton• examine security credentials• start or join transaction• call any necessary persistence functions• trigger various callbacks• call business logic• more work with transactions, persistence and callbacks• send back result or an exceptionEJB Container95-702 Organizational Communication Technologies4Enterprise Java Beans•Server-Side EJB objects may offer a remote view (via a remote procedure call protocol) a local view (direct procedure call) or both•Managed EJB container services are more involved than the plain old JVM•Components distributed in binary format and are configurable95-702 Organizational Communication Technologies5Server-Side Implications•In order to pull off the RPC trick we need:•A naming service -- e.g. RMI clients make requests on the rmiregistry•RPC proxies -- communications code along with the appropriate interface95-702 Organizational Communication Technologies6Managed: EJB Container Services•Object Persistence and Synchronization•Declarative Security Control•Declarative Transaction Control•Concurrency Management•Scalability Management95-702 Organizational Communication Technologies7EJB Types•Entity Beans•Session Beans•Message-Driven Beans95-702 Organizational Communication Technologies8EJB Types•Entity Beans•Session Beans•Message-Driven Beans }}RMI-based server side componentsAccessed using distributed objectProtocols (RMI IIOP)New in EJB 2.0Asynchronous server sidecomponent that responds toJMS asynchronous messages(Think provider like JAXM)95-702 Organizational Communication Technologies9Entity Beans•Represent real world entities (customers, orders, etc.)•Persistent Objects typically stored in a relational database using CMP (Container Managed Persistence) or BMP (Bean Managed Persistence)•The client sees no difference between CMP and BMP beans•CMP promotes component portability (less reliant on the container)95-702 Organizational Communication Technologies10Session Beans•Are an extension of the client application•Manage processes or tasks•Are not persistent•Often employ several different kinds of entity beans•Implement business logic•Come in two types (which can be more easily shared?)–Stateless session beans (no memory between calls) purchase(severalIems,creditCardNo);–Stateful session beans (remember earlier calls) addToCart(item); purchase(creditCardNo);95-702 Organizational Communication Technologies11Message-Driven Beans•Work in cooperation with Java Messaging System (JMS)•JMS is an abstraction API on top of Message-Oriented Middleware (MOM) – like JDBC is an abstraction API on top of SQL databases•Each MOM vendor implements things differently•MDB’s allow the developer to program using the publish-subscribe messaging model based on asynchronous, distributed message queues•The MOM vendor need only provide a service provider for JMS (IBM’s MQSeries or Progress’ SonicMQ)95-702 Organizational Communication Technologies12Message-Driven Beans•Are like session beans•Have no persistent state •Coordinate tasks involving other session beans or entity beans•Listen for asynchronous messages•Unlike Session beans, provide no remote interface describing the methods that can be called95-702 Organizational Communication Technologies13Message-Driven Beans•Are receivers of MOM messages coming through the JMS API.•Usually take action when a message is received.•Unlike session and entity beans, Message-Driven Beans expose no remote or local view. They are not called directly by a client.95-702 Organizational Communication Technologies14Before working with EJB’s•Understand the role of JNDI (Java Naming and Directory Interface)95-702 Organizational Communication Technologies15Naming• Concepts from the JNDI Tutorial• Java Naming and Directory Interface95-702 Organizational Communication Technologies16Naming Concepts•We need to map people friendly names to objects•Examples [email protected] -> Mike’s mailbox www.cnn.com -> cnn’s web server c:\somedir\f1.dat -> a file on a C drive95-702 Organizational Communication Technologies17Naming Conventions•Different naming systems use different conventions (or syntax) for names•Examples: DOS uses slashes and colons and periods c:\some\f.dat Unix uses slashes /usr/local/filename DNS uses dots www.cnn.com LDAP (The lightweight directory access protocol) uses name, value pairs cn=Rosanna Lee, o=Sun, c=US95-702 Organizational Communication Technologies18Bindings•A binding is the association of a name with an object or an object reference. Examples: www.cnn.com is bound to an IP address c:\exam1.doc is bound to a file a phone number is bound to a phone95-702 Organizational Communication Technologies19Bindings•A binding is the association of a name with an object or object reference. The phone book maps names to numbers which act as references to objects. The number is a communication endpoint.•A communication endpoint is specific information on how to access an object95-702 Organizational Communication Technologies20ContextA context is a set of name-to-object bindings.Every context has an associated
View Full Document