Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to JEE

Introduction to JEE

Presented for Thessaloniki Java meetup June 2014

Papapetrou Patroklos

June 13, 2014
Tweet

More Decks by Papapetrou Patroklos

Other Decks in Technology

Transcript

  1. 1 Introduction to JEE Thessaloniki Java Meetup June 2014 Presentation

    by Patroklos Papapetrou Twitter hashtag : #skgjee @ppapapetrou76 @ppapapetrou76 #skgjee JSE vs JEE Overview Business components JEE Servers Example
  2. 2 Introduction to JEE Thessaloniki Java Meetup June 2014 Presentation

    by Patroklos Papapetrou Twitter hashtag : #skgjee @ppapapetrou76 @ppapapetrou76 #skgjee JSE vs JEE Overview Business components JEE Servers Example
  3. 3 @ppapapetrou76 #skgjee Agenda JSE vs JEE Overview Business components

    JEE Servers Example • Java SE vs Java EE • Overview • The layers • JEE Servers
  4. 4 Java SE vs Java EE @ppapapetrou76 #skgjee JSE vs

    JEE Overview Business components JEE Servers Example
  5. 6 @ppapapetrou76 #skgjee JSE vs JEE Overview Business components JEE

    Servers Example Java Virtual Machine The father of all evils
  6. 9 @ppapapetrou76 #skgjee Enterprise Applications JSE vs JEE Overview Business

    components JEE Servers Example • Large-scale, multi-tiered, scalable, reliable & secure network(web) applications • Applications used mostly by large enterprises • JEE offers a development model, APIs, services • Developers can concentrate on the real meat
  7. 10 @ppapapetrou76 #skgjee N-tier (Layered) Architecture JSE vs JEE Overview

    Business components JEE Servers Example • Client Layer (Client Tier) • Presentation Layer (Web Tier) • Business Logic Layer (Business Tier) • Persistence Layer (Enterprise Information Systems Tier) • Data Layer
  8. 11 @ppapapetrou76 #skgjee Presentation Layer JSE vs JEE Overview Business

    components JEE Servers Example • Transforms and presents data in predefined format , readable to end-users • Handles user input and passes requests to business logic layer
  9. 12 @ppapapetrou76 #skgjee Business Logic Layer JSE vs JEE Overview

    Business components JEE Servers Example • Heart of the system • Contains workflow business rules and processing logic • Utilizes the persistence tier to retrieve and save data into the persistence storage
  10. 13 @ppapapetrou76 #skgjee Persistence Layer JSE vs JEE Overview Business

    components JEE Servers Example • Provides a high-level object- oriented (OO) abstraction over the database layer • Responsible for fetching and persisting data.
  11. 14 @ppapapetrou76 #skgjee Database Layer JSE vs JEE Overview Business

    components JEE Servers Example • Provides access to databases or other structured documents • Typically consists of a relational database management system or a No-SQL database
  12. 15 The Business Componets & the Technologies @ppapapetrou76 #skgjee JSE

    vs JEE Overview Business components JEE Servers Example
  13. 16 @ppapapetrou76 #skgjee Persistence Layer JSE vs JEE Overview Business

    components JEE Servers Example Java Database Connectivity API (JDBC) Low level API for managing data using sql queries
  14. 17 @ppapapetrou76 #skgjee Persistence Layer JSE vs JEE Overview Business

    components JEE Servers Example Java Persistence API (JPA) Higher level API for mapping data to Java objects
  15. 18 @ppapapetrou76 #skgjee Persistence Layer JSE vs JEE Overview Business

    components JEE Servers Example Java Transaction API (JTA) API for managing transactions (across multiple or distributed datasources)
  16. 19 @ppapapetrou76 #skgjee Persistence Layer - Entities JSE vs JEE

    Overview Business components JEE Servers Example • Enterprise Java Beans (EJB) • Persistence : The ability to have data contained in Java objects automatically stored in a datasource • Managed by JPA using a techique called object- relational mapping (ORM) • Persistence provider : A framework that supports JPA
  17. 20 @ppapapetrou76 #skgjee JSE vs JEE Overview Business components JEE

    Servers Example @Entity @Table(name = "car") public class Car implements Serializable { @Id @Basic(optional = false) @NotNull @Column(name = "id") private Integer id; @Size(max = 12) @Column(name = "plate_number") private String plateNumber; @JoinColumn(name="model_id",referencedColumnName= "id") @ManyToOne(optional = false) private Model model; }
  18. 21 @ppapapetrou76 #skgjee Business Logic Layer JSE vs JEE Overview

    Business components JEE Servers Example EJB Services • Concurrency • Thread safety • Transactions • Security • Remoting • Web Services • Timers • Interceptors
  19. 22 @ppapapetrou76 #skgjee Business Logic Layer JSE vs JEE Overview

    Business components JEE Servers Example Session Beans • Encapsulate the business process of an enterprise application • Every business process should be completed within a Session • Are the only EJB Components allowed to be directly invoked by the client
  20. 23 @ppapapetrou76 #skgjee Business Logic Layer JSE vs JEE Overview

    Business components JEE Servers Example Session Beans Flavors Stateless Stateful
  21. 24 @ppapapetrou76 #skgjee JSE vs JEE Overview Business components JEE

    Servers Example @Stateless public class CarSearchBean { @EJB private CarFacade carFacade; public List<Car> searchCars(CarSearchCriteria criteria){ return carFacade.findByPlateModelColor(criteria); } }
  22. 25 @ppapapetrou76 #skgjee Business Logic Layer JSE vs JEE Overview

    Business components JEE Servers Example Web Services (RestFul) @Path("/") public class CarsService { @EJB private CarFacade carFacade; @GET @Path("/cars") @Produces({"application/json"}) public Response getCars(@DefaultValue("opel") @QueryParam("modelName") String model) { return Response.status(200).entity(getCars(model)).type(“applic ation/json”).build(); } }
  23. 26 @ppapapetrou76 #skgjee Business Logic Layer JSE vs JEE Overview

    Business components JEE Servers Example Web Services (SOAP) @WebService(serviceName = "carSearchService") public class CarSearchBeanWS { @EJB private CarFacade carFacade; @WebMethod(operationName = "searchCarsByCriteria") public @WebResult(name = "cars") List<CarWs> searchCars(@WebParam(name = "searchCriteria") CarSearchCriteria criteria) { return carFacade.getCars(criteria); }
  24. 28 @ppapapetrou76 #skgjee Presentation Layer JSE vs JEE Overview Business

    components JEE Servers Example • Frontend – Java Server Pages (JSP) – Java Server Faces (JSF) – Java Server Faces facelets (XHTML) • Backend – Servlets – Managed (backing) beans
  25. 29 @ppapapetrou76 #skgjee Presentation Layer JSE vs JEE Overview Business

    components JEE Servers Example <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets" template="templates/default.xhtml"> <ui:define name="content"> <center> <h:outputText value="#{messages.message_welcome}" styleClass="text-size-14"/> <p:separator/> <p:graphicImage value="resources/images/Carrental.jpg" /> </center> </ui:define> </ui:composition>
  26. 30 @ppapapetrou76 #skgjee Presentation Layer JSE vs JEE Overview Business

    components JEE Servers Example <h:form id="searchCarsForm"> <p:messages id="messages" /> <p:panel id="panel" header="#{messages.label_search_criteria}" style="margin-bottom:10px;"> <h:panelGrid id="searchCarsPanelGrid" columns="4"> <h:panelGroup> <p:outputLabel id="carModelInputLbl" for="carModelInput" value="#{messages.label_car_model} :"/> <p:inputText id ="carModelInput" value="#{carBean.criteria.modelName}" required="true"> <f:validateLength minimum="2"/> </p:inputText> </h:panelGroup> <p:message id="carModelInputMsg" for="carModelInput"/>
  27. 33 @ppapapetrou76 #skgjee Web Container • Interface between web components

    and web server • Manages component's lifecycle, dispathces requests to application components • Provides interfaces to context data (request, response information) JSE vs JEE Overview Business components JEE Servers Example
  28. 34 @ppapapetrou76 #skgjee EJB Container • Interface between EJBs and

    the JEE server • Runs on a Java EE server • Manages the execution of and lifecycle of EJBs JSE vs JEE Overview Business components JEE Servers Example
  29. 35 @ppapapetrou76 #skgjee Popular JEE Implementations • JEE Containers –

    JBoss Wildfly – Oracle Glassfish • JPA Engines – Hibernate – TopLink – OpenJPA JSE vs JEE Overview Business components JEE Servers Example
  30. 36 @ppapapetrou76 #skgjee Popular JEE Implementations • JSF Implementation –

    Apache MyFaces • JSF Component Libraries – PrimeFaces (Really Rock!!) – RichFaces • The whole specification – Spring Framework JSE vs JEE Overview Business components JEE Servers Example