1 / 14

CSE446 Software Quality Management

CSE446 Software Quality Management. Orhan Ba şar Evren. Spring 2014. Yazılım ve Uyguluma Geliştirme Yöneticisi. Today’s Overview. EJB : Enterprise Java Beans What is EJB ? EJB Container Bean Types Remote and Local Examples JPA and EJB. EJB – Enterprise Java Beans.

hastin
Download Presentation

CSE446 Software Quality Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSE446 Software Quality Management Orhan Başar Evren Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi

  2. Today’s Overview • EJB : Enterprise Java Beans • What is EJB ? • EJB Container • Bean Types • Remote and Local • Examples • JPA and EJB CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  3. EJB – Enterprise Java Beans • EJB technology is a server-side component architecture that enables rapid and simplified development of distributed, transactional, secure, and portable applications. • Enterprise beans run in the EJB container • Server-side component that encapsulates the business logic of an application. CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  4. EJB – EJB Container • Container is holding objects on server • Container creates and manages enterprise bean instances at runtime • Container isolates beans from clients • Transaction Management • Persistence Management • Security Management • Containers provide JNDI service CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  5. EJB – EJB Container CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  6. EJB – Bean Types • Session Bean:High level business logic and processes • Message Driven Bean: Integrate with external services via asynchronous messages using JMS (Java Messaging Service) CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  7. EJB – Session Beans • Invoked by a client in order perform a business operation. The bean instance is available for the duration of a unit work. • @Stateless: used for operations that can occur in a single method call • @Stateful: State is maintained across multiple method calls. • @Singleton: Bean is instantiated once per application CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  8. EJB – Session Bean Example @Stateless public class CalculatorBeanimplements Calculator { public intadd (int n1, intn2) { return n1 + n2; } public intsubtract(intn1, intn2) { return n1 – n2; } } CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  9. EJB – Session Bean Example @MessageDriven public classCalculatorBean implements MessageListener { public void onMessage(Message message) { System.out.println("A message arrived!"); } } CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  10. EJB – Remote and Local Interfaces • @Remote: Used to allow remote access. Clients can call those methods from another java EE applications, or from other java SE desktop applications. Beans are remotely accessed using JNDI . (Java Naming and Directory Interface) • @Local : Allow only local access within the container. Beans locally accessed using @EJB annotation CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  11. EJB – Local Access Example @ManagedBean public class JSFBean { @EJB Calculator calc; public voiddoMath() { intresult = calc.add(10,5); } } CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  12. EJB – Remote Access Example public class DesktopClient { public static void main(String[] args) { InitialContextic = new InitialContext(); Calculator calc = (Calculator) ic.lookup("java:comp/env/app/Test"); int result = calc.add(10, 5); } } JNDI , URL, and other information can be stored on a properties file. CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  13. EJB – Security and Transaction @Stateless @DeclareRoles({“user" “admin"}) public class RegistrationService { @RolesAllowed({“user"}) public void register(String event) { … } @RolesAllowed({“admin”}) public voidcreate(String event) { … } @Transactional public voidcreateAndRegister(String event) { create(event); register(event); } } CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  14. EJB –Other Examples • Demonstration of @EJB usage with in Web Application to manage transactions. • Demonstration of Java Enterprise Application with simple math functionalities as business logic. (Use of ear files) • Accessing business logic locally from a JSF managed bean • Accessing business logic remotely from a Desktop app. CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

More Related