95-702 Distributed SystemsSlide 2Slide 3Slide 4From The Java EE TutorialSlide 6Slide 7Benefits of Enterprise Beans(1)Benefits of Enterprise Beans(2)Main Concept: InterpositionThe Container Implements the component interface (From Eckel)Enterprise Java BeansServer-Side ImplicationsManaged: EJB Container ServicesEJB TypesSlide 16Entity Beans (1)Entity Beans (2)Entity Beans (3)Entity Bean(4)Session BeansSession Bean QuizImplementing Entity and Session BeansMessage-Driven Beans (1)Message-Driven Beans (2)Message-Driven Beans (3)Message-Driven Bean (4)Message-Driven Bean (5)In Both Messaging ModelsPoint-to-point on the Client SidePoint-To-Point on the Server SideMessage Driven Beans (6)Slide 33On The ClientSlide 35JMS Message Types(1)JMS Message Types(2)Listening to the QueueWeb ServicesA Stateless Session Bean as a Web ServiceThe Web Service Endpoint InterfaceThe Web Service Session Bean95-702 OCT1Master of Information System Management95-702 Distributed SystemsLecture 19: Enterprise Java Beans95-702 OCT2Master of Information System Management• Advanced Java 2 Platform How to Program by Deitel, Deitel, & Santry• Thinking in Enterprise Java Bruce Eckel et. Al.• EJB 3.0 API Sun documentation http://java.sun.com/products/ejb/docs.html• Java Enterprise In A Nutshell Farley, Crawford & FlanaganSome Useful Resources95-702 OCT3Master of Information System ManagementFrom The Java EE TutorialServletsJSP’sAxis2HTMLSession beansEntity beansMessage Driven Beans95-702 OCT4Master of Information System ManagementFrom The Java EE Tutorial95-702 OCT5Master of Information System ManagementFrom The Java EE Tutorial95-702 OCT6Master of Information System ManagementSOAP and Java EESlide from JAXM/JMS tutorial at Sun Microsystems95-702 OCT7Master of Information System ManagementSlide from JAXM/JMS tutorial at Sun Microsystems95-702 OCT8Master of Information System ManagementBenefits of Enterprise Beans(1) •Simplify development of large, distributed applications.•The developer can concentrate on business problems.•The EJB container handles transaction management, security, and authorization.•Portable – may be moved to other Java EE containers.95-702 OCT9Master of Information System ManagementBenefits of Enterprise Beans(2) •Scalable – the components may be distributed across many machines.•Support for Location Transparency – the client need not be concerned with the location of the bean.•Support for Transaction management - ensures data integrity (over concurrent access of shared resources).•Promotes thin clients and web services.95-702 OCT10Master of Information System ManagementMain Concept: InterpositionApplicationstub 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 OCT11Master of Information System ManagementThe Container Implements the component interface (From Eckel)95-702 OCT12Master of Information System ManagementEnterprise Java Beans•Part of Java EE Enterprise Application Technologies•Currently at EJB3.0 (Big simplification of code with annotations – less concern with configuration files)•Server-side managed components•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 OCT13Master of Information System ManagementServer-Side Implications•In order to pull off the RPC trick we need:•A naming service -- Recall how RMI clients make requests on the rmiregistry. -- A stand alone EJB client would use a global JNDI name. InitialContext ic = new InitialContext(); // provider properties Foo foo = (Foo) ic.lookup("FooEJB"); // and address of // naming service // found in // jndi.properties •RPC proxies -- communications code along with the appropriate interface95-702 OCT14Master of Information System ManagementManaged: EJB Container Services•Object Persistence•Declarative Security Control•Declarative Transaction Control•Concurrency Management•Scalability ManagementThe programmerneed not worryabout the details.Think “JVM onsteroids”.95-702 OCT15Master of Information System ManagementEJB Types•Entity Beans•Session Beans•Message-Driven Beans95-702 OCT16Master of Information System ManagementEJB Types•Entity Beans•Session Beans•Message-Driven Beans}}RMI-based server side componentsAccessed using distributed objectProtocols (RMI IIOP)New since EJB 2.0Asynchronous server sidecomponent that responds toJMS asynchronous messages(Think provider like JAXM)95-702 OCT17Master of Information System ManagementEntity Beans (1)•Represent a row of a relation. O/R mapping.•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 (more reliant on the container to handle detail). •CMP uses its own Query Language EJB QL.•CMP relies on an Abstract Schema in the deployment descriptor.95-702 OCT18Master of Information System ManagementEntity Beans (2)•Define a primary key class: –Required for entity beans. –Provides a pointer into the database.–Must implement Java.io.Serializable.•The EJB instance represents a particular row in the corresponding database table.•The home interface for the entity EJB represents the table as a whole (has finder methods.)95-702 OCT19Master of Information System ManagementEntity Beans (3)•The primary key can be used by the client to locate the bean•Rows may have columns that reference other entity beans (e.g. an order has a buyer)•These relationships may be managed by the bean or by the container (container managed relationships)95-702 OCT20Master of Information System ManagementEntity Bean(4) OrderEJB CusomerEJB 1 Many 1 Many LineItemEJB ProductEJB Many 1A relationship field is like a foreign key in a database.If a b then a “knows about” or “holds a pointer
View Full Document