1 / 36

Java EE Web Application Development with JDeveloper 10gR3

Learn about the Java EE platform and its components like EJB, JavaServer Faces, and data binding. Discover the benefits of Java EE, its architecture, and how to develop multi-tiered web applications.

phillipbell
Download Presentation

Java EE Web Application Development with JDeveloper 10gR3

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. Java EE Web-Application with JDeveloper 10gR3 • EJB3.0 • Databinding • Java Server Faces – ADF-Faces

  2. Java EE Platform • Is a multitiered, distributed application model • Supports component-based Java EE applications • Distributes the application logic to the appropriate tier on the multitiered architecture

  3. Java EE Application 1 Java EE Application 2 Client Tier Application Client Dynamic HTML Pages Web Tier JSP Pages Enterprise Beans Enterprise Beans Business Tier Distributed Multitiered Applications Client Machine Java EEServer Database Server EIS Tier

  4. Java EE Architecture Java EE Server Client Machine Web Container Browser Java Servlet/JSF Application Client Container Application Client EJB EJB Business services container APIs Database JNDI JTA JMS RMI JDBC JAF JavaMail

  5. Benefits of the Java EE Platform • “Write once, run anywhere” provides simplified component development. • Multiple server products and vendors support the Java EE standard, thus giving more deployment choices. • Java EE separates client requirements from business logic. • It provides multiple development and design scenarios. • It allows multiple clients to share server business logic.

  6. Benefits of the Java EE Platform • Java EE separates development tasks into specific skill areas: • Web designers can create JSF components. • Java programmers and business experts create business logic and rules. • Production environment teams can handle assembly and deployment.

  7. Java EE Components • Java EE applications are made up of components. • A component is an application-level software unit. • Components can be easily updated as business needs change. • Components are reusable. • There are several types of components: • Client-side components • Web components • Business-tier components

  8. Java EE 5.0 Components The Java EE 5.0 Specification lists the following components: • Java Servlet 2.5 • JavaServer Pages 2.1 • Enterprise JavaBeans 3.0 • Java API for XML-BasedWeb Services 2.0 • Java API for XML-Based RPC 1.1 • Web Service Metadatafor the Java Platform • Java Message Service API • Java Transaction API • Java Persistence API • J2EE Connector Architecture 1.5 • SOAP with Attachments API for Java (SAAJ) • Streaming API for XML

  9. Enterprise JavaBeans (EJB) • Enterprise JavaBeans: • Are server-side components written in Java • Contain the business logic of an enterprise application • Are hosted in EJB containers • Are based on Remote Method Invocation (RMI) communication • Are platform independent • Provide remote services for clients • Can be exposed as Web services • Use JDBC to connect to a database

  10. Types of EJB • Entity bean • Used to model the persistence part of an application • Session bean • Invoked by a client to perform a specific business operation • Message-driven bean • Triggered by messages sent to a messaging server which enables sending asynchronous messages between system components

  11. The Java Persistence API The Java Persistence API (JPA) deals with: • The way relational data is mapped to Java objects (“persistent entities”) • The way these objects are stored in a relational database so that they can be accessed at a later time • The continued existence of an entity’s state even after the application that uses it, ends

  12. Java EE Web-Tier Components • A Web tier may consist of: • Java servlets • JSPs • Servlets and JSPs: • Work on a request-response model • Generate HTML dynamically • Access the database through JDBC • Access the business-tier components • Handle user-centric events, such as an HREF link or form submission • Usually generate visual interfaces such as a Web page

  13. What Is a Servlet? Servlet Browser Client info (host name, form data) Success or failure Process results (access database) Format results and produce HTML Send page back to client Request Response

  14. What Is a JavaServer Page (JSP)? • A JSP: • Is a text-based document that includes: • HTML • JSP tags • Java code (including calls to JavaBeansand servlets) • Cleanly separates content creation from presentation logic • Focuses on rapid development and easy modification of the user interface • Focuses on presentation

  15. What Is JavaServer Faces (JSF)? • JSF: • Is a server-side component framework for Web applications • Implements the Model-View-Controller (MVC) framework • Provides separation of navigational and data flow • Built for RAD style development

  16. JSF: Overview • JavaServer Faces (JSF) provides the same benefits as the Struts architecture, including: • Controller servlet (MVC implementation) • Declarative and visual design in JDeveloper • XML configuration file (faces-config.xml)

  17. Web-Tier Components: Summary • Web-tier components generate dynamic content. • Servlets: • Extend Web server functionality • Are best used for business logic • JSPs: • Combine HTML (or other markup) and Java • Are best used for presentation logic • JSFs: • Are component based • Implement MVC

  18. Client-Tier Components • A Web browser: • Is used for a Web-based Java EE application • Downloads static or dynamic Web pages fromWeb-tier components • Is a thin client • An application client: • Is used for a non-browser-based Java EE application • Executes on the client machine • Can contain a graphical or command-line interface • Is a thick client • Accesses middle-tier services • Requires installation on the client machine

  19. What Is Persistence? • The persistence layer provides mapping between objects and database tables. • This layer: • Enables portability across databases and schemas • Supports read and write capabilities • Protects developers from database issues • Should be used in any application that has an object model

  20. Persistence: Overview • Mapping relational database objects to Java objects enables easy Java EE application development. • Frameworks such as EJB 3.0 JPA provide this object-relational mapping. Entity/JPA Persistence Architecture Schema Java model

  21. JPA Entities • Consistent persistence mechanism • Java Persistence API (JPA) • Simple programming model • POJO persistence (Plain Old Java Interface) • Object-Relational mapping annotations • Getter/setter methods • Can contain logic (validation and so on) • The EntityManager object • Handles data manipulation • Enables entities to be called outside the container

  22. Entity Annotations • @Entity • @Id • @IdClass • @EmbeddedId • @Table, @SecondayTable • @UniqueConstraint • @PrimaryKeyJoinColumn(s) • @NamedQuery(s) • Sequencing • @GeneratedValue • @SequenceGenerator • @TableGenerator

  23. How Do JPA Entities Work? • A JPA entity: • Is a lightweight object that manages persistence data • Is defined as a Plain Old Java Object (POJO) marked with the Entity annotation (no interfaces required) • Must implement the java.io.Serializable interface to be passed by value to a remote application • Is mapped to a database by using annotations @Entity @Table(name=“PRODUCTS") @Id @Column(name=“PRODID") ORDERS POJO Database

  24. Mapping Relationships Between Entities • Annotations for entity relationships: • OneToOne • OneToMany • ManyToMany andAssociationTable User Address ServiceRequest ServiceHistory Products Users

  25. Writing Basic JPA QL SELECT Statements • Syntax for a JPA QL SELECT statement: • JPA QL Named Query example: • Find all Products. SELECT [DISTINCT] select_expression FROM abstract_schema_name [AS] identifier_variable [WHERE conditional_expressions(s)] [ORDER BY order_by_item(s)] @NamedQuery(name = "Products.findAll", query = "select o from Products o"),

  26. What Is a Session Bean? • A session bean is a type of Enterprise JavaBean (EJB) that: • Implements a business process • Represents a client/server interaction • Has a short lifespan • Lives in memory rather than in persistent storage • Is used to create a session facade

  27. Stateless Versus Stateful Session Beans • There are two types of session beans: • Stateless session bean (SLSB) • Conversation is contained in a single method call. • Business process does not maintain client state. • Stateful session bean (SFSB) • Conversation may invoke many methods. • Business processes can span multiple method requests, which may require maintaining state. EJB container EJB container Pool of SLSBs SFSBs Client 1 Client 1 Client 2 Client 2

  28. Elements of a Stateless Session Bean • A stateless session bean contains: • Business interfaces, which contain the business method definition • A bean class, which implements the business method JVM @Remote @Stateless String sayHello() StringsayHello() { return "Hello"; } Remote client @Local String sayHello() Local client Interfaces Bean class

  29. ADF Architecture ADF Swing ADFFaces Swing JSP JSF View ADFController Controller Struts JSF Model ADFModel XML WebServices EJB + TopLink ADFBusinessComponents JavaBeans Business Services

  30. Model Layer Components • Data controls describethe public interface of a business service. • Bindings connect UI components to data or actions. • Data controls and bindings are defined using XML metadata. Bindings Bindings Data control Business service

  31. JSF Components • JSF Components consists of three parts: • UI components: Functionality, attributes, or behavior • Renderers: Converts components to and from a specific markup language • Render kits: Library of renderers (Basic HTML RenderKit is part of the specification.)

  32. JSF UI Components • Are the basic building blocks of a JSF application • Are stateful server objects • Do not define rendering • Can represent simple to complex user interface components ranging from a button or input field to a complete page • Can be associated to model data objects through value binding • Can use helper objects such as validators, converters, listeners, and events

  33. JSF Architecture HTML browser Front controller Page Backendcode HTML render kit Page Phone/ PDA WML render kit

  34. Managed Beans • Managed beans can: • Store state • Execute a Java routine • Define a handler for event listeners • They have no-argument constructors. • Lazy initialization is performed by JavaServer Faces. • Access scope: None, Request, Application, or Session • Backing beans: • Are special types of managed beans • Contain getter and setter methods for UI components

  35. Expression Language • Dot notation for attributes (JavaBean model):#{userbean.name} same as instance.getName(); • Map notation:#{foo["baa"]} same as instance.get("baa"); • Expressions can be of any depth:#{foo["baa"].person.name} • Expressions can evaluate:#{userbean.name} same as foo["baa"].person.name}  true|false

  36. JSF Navigation Diagram

More Related