Tuesday, January 16, 2018

Introduction to Java Platform, Enterprise Edition

Companies need distributed, transactional and portable applications: enterprise java applications fulfill the business logic for the enterprise.

Java platform provides APIs to developers and shortens developement time

The Java Community Process (JCP) writes Java Specification Requests (JSRs) to define the Java EE technologies

The Java EE 7 platform simplifies the programming model:

  • Developers can use annotations in Java source files, instead of optional XML deployment descriptors. The Java EE server reads annotations and configures components at deployment and runtime
  • With dependency Injection, required resources can be injected in component, instead of using JNDI lookup code. Dependency injection can be used in any container type: EJB container, web container and application client container. The container is aware of annotations and inject references to other component/resource

1 Java EE Application Model

Java EE applications implement enterprise services for customers, access data from different sources and distribute applications to a variety of clients

The business functions of Java enterprise applications are in the middle tier: the middle tier is usually on a dedicated server hardware.

The Java application model architecture implements the customer's services as multitier applications

The Java model partitions the work in two parts:

  • business logic and presentation implemented by developers
  • standard services provided by Java EE platform

2 Distributed Multi Tier Applications

The Java enterprise platform uses distributed multitiered application model:

  • applications divide logic into components
  • application components are installed on various machines depending on the tier they belong

The figure shows two multi-tier Java EE applications divided in tiers:

  • the client tier components on the client machine
  • the web-tier components on the Java server
  • the business tier components on the Java server
  • the Enterprise information tier software on the EIS server

Java EE applications are three-tiered applications because they are distributed over three locations: client machine, the Java server and the database or legacy-machine

  • the three tiered applications extends the two tiered client-server model placing an application server between the client application and back-end storage.
2.1 Security

The Java EE security environment enables security constraints to be defined at deployment time

The Java EE platform provides:

  • declarative access control rules
  • standard login mechanisms
2.2 Java EE Components

A Java EE component is a functional software unit:

  • components are assembled into a Java EE application, with its related classes and files

The Java EE specification defines the following Java EE components:

  • components that run on the client: application clients and applets
  • web components running on the server: Servlets, JavaServer Faces and JavaServer Pages
  • business components running on the server: EJB components or enterprise beans

What is the difference between Java EE components and standard Java classes?

  • Java EE components are assembled into a Java EE application
  • Java EE components must be in compliance with the Java EE specifications
  • Java EE components are managed by a Java EE server
2.3 Java EE Clients

Java client components are either a web client or an application client

Web Clients
  • a web client component consists of two parts: dynamic web pages and a web browser
  • a web client is also called a thin client, because they delegate heavyweight operations to enterprise beans
Application Clients

An application client runs on a client machine and provides user with a richer user interface (GUI)

  • application clients access enterprise beans running on the business tier
The JavaBeans Component Architecture

Server and client tiers may include components based on the JavaBeans architecture

  • JavaBeans components are not considered Java EE components in the Java specification
  • JavaBeans manage the data flow between the following:
    • application clients and components running on the Java EE server
    • server components and a database

Clients Server Communications

The clients communicates with the business tier in the Java EE server in two ways: either directly or going through servlets in the web tier

2.4 Web Components

Java EE web components are either servlets or web pages created with JSF or JSP technologies

  • servlets are Java classes that dinamically process requests and responses
  • JSP pages are text-based documents which allow a natural approch to creating content
  • JSF builds on servlets and JSP and provide a UI component framework for web apps

static HTML pages and utility classes are included with web components but not considered web components

JavaBeans are included in the web tier to manage user input and send data to enterprise beans

2.5 Business Components

The business code is handled by enterprise beans

  • the business code is logic that solves the needs of a particular business domain
  • enterprise beans run either on the business tier or on the web tier
2.6 Enterprise Information System Tier

The enterprise information system tier includes enterprise infrastructure system such as:

  • enterprise resource planning (ERP)
  • mainframe transaction processing
  • database system
  • legacy information system

3 Java EE Containers

Multi-tier application are hard to write because they involve a lot of code to handle transactions, security, multithreading et cetera.

Java EE applications are easy to write for two reasons: application logic is organized into reusable components, besides the Java EE server provides services in the form of container for every component type so that developers only have to solve business problem.

3.1 Container Services

Containers are the interface between a component and the functionalities that support the component

To execute a component, it must be assembled into a Java EE module and deployed into its container

The assembly process involves specifying the configuration settings for each component and for the Java application itself

  • the container settings customize the support provided by the Java EE server
  • the Java EE server support includes such services as security, transaction management, Java Naming and Directory Interface (JNDI) API and remote connectivity (RMI) API
3.2 Container Types

The server and containers are:

  • Java EE server: provides EJB and web container
  • EJB container: manages the execution of enterprise beans
  • Web container: manages the execution of web pages and some EJB components
  • Application client container: manages the execution of application client components

4 Web Services Support

Web services are web-based application that use standard based transport protocols to exchange data with clients

  • the Java platform provides APIs and tools to develop web services and clients that interoperate with other web services developed in Java or other languages

5 Java EE Application Assembly and Deployment

A Java EE application is packaged into one or more standard units

  • application units can be deployed to any Java EE compliant system
  • application units contain:
    • application components, such as web pages and enterprise beans
    • an optional deployment descriptor that describes the content

6 Java EE 7 APIs

6.1 Java Servlet Technology (since j2ee 1.2)

Java Servlet tecnology allow to define HTTP-specific servlet classes

  • a java servlet class extends the capabilities of web servers

Java EE 7 platform new Java Servlet technology features includes: Nonblocking I/O and HTTP protocol upgrade

6.2 JavaServer Pages Technology (JSP since j2ee 1.2)

JavaServer Pages technology allow to write snippets of servlet code directly into a HTML documents. The Java EE 7 platform recommends the use of Facelets as view technology.

6.3 JavaServer Pages Standard Tag Library (JSTL since j2ee 1.2)

JavaServer Pages Standard Tag Library contains core functionality that are common to JSP applications.

6.4 Enterprise JavaBeans Technology (EJB since j2ee 1.2)

An EJB component is a class that implement a unit of business logic

Enterprise beans are either session beans or message-driven beans

New Java EE 7 platform EJB features include EJBLite

6.5 Java Transaction API (JTA since j2ee 1.2)

The Java Transaction API (JTA) provides a standard interface for demarcating transactions. The JTA API is useful to demarcate transactions that spans over two separate database access operations.

6.6 Java Message Service API (JMS since j2ee 1.2)

The Java Message Service API is a standard for messaging that allows Java EE application components to send and receive asynchronous messages.

6.7 JavaMail API (since j2ee 1.2)

Java EE applications use the JavaMail API to send email messages.

6.8 Java EE Connector Architecture (JCA since j2ee 1.3)

Java EE Connector Architecture (JCA) is a technology for connecting application servers and enterprise information systems (EIS). The Java EE Connector Architecture API enables tools vendors and system integrators to create resource adapters.

6.9 Java Authorization Contract for Containers (JACC since j2ee 1.4)

The Java Authorization Contract for Containers specification defines a contract between a Java application server and a provider that creates an authorization policy.

6.10 JavaServer Faces Technology (JSF since Java EE 5)

JavaServer Faces technology is a user interface framework for building web applications

6.11 Java Persistence API (JPA since Java EE 5)

The Java Persistence API (JPA) is the standard API for persisting the state of objects to a relational database, the object-relational mapping (ORM) API. The JPA API can be used in Java SE applications or in the Java EE environament

6.12 Java API for RESTful Web Services (since Java EE 6)

The Java API for RESTful Web Services (JAX-RS) defines APIs for developing web services built following the REST architectural style.

6.13 Managed Beans (since Java EE 6)

Managed Beans are POJO objects treated as managed component by the Java EE container

Manage Beans:
  • are a generalization of JSF managed bean: JSF managed beans are used only in web modules, Managed Beans can be used anywhere in a Java EE application
  • supports the basic services: resource injection, lifecycle callbacks and interceptors
  • provides a common foundation for the different kinds of component: CDI Beans and EJBs
6.14 Contexts and Dependency Injection for Java EE (CDI since Java EE 6)

Contexts and Dependency Injection for Java EE defines a set of containers' services for using CDI managed beans (for example Managed Beans or EJBs) in web applications.

  • CDI managed beans, compared to Managed Beans, add support for lifecycle scopes and events.
6.15 Dependency Injection for Java (since Java EE 6)

Dependency Injection for Java defines a standard set of annotations for use on injectable classes.

  • The Java CDI API supports Dependency Injection: you can inject beans using @Inject annotation only in a CDI-enabled application.
6.16 Bean Validation (since Java EE 6)

The Bean Validation specification allows the developer to define the validation of data of JavaBeans in a single layer of the application.

6.17 Java Authentication Service Provider Interface for Containers (JASPIC since Java EE 6)

The Java Authentication Service Provider Interface for Containers (JASPIC) specification defines a service provider interface (SPI) by which authentication providers may be integrated in containers that do message-processing.

6.18 Java API for WebSocket (new in Java EE 7)

WebSocket is a protocol that provides full-duplex communication channels over a single TCP connection: this API enables the creation of WebSocket endpoints using annotations.

6.19 Java API for JSON Processing (JSON-P new in Java EE 7)

JSON is a text-based data format used to exchange data over HTTP. The Java API for JSON Processing enables Java EE applications to handle JSON data using streams.

6.20 Concurrency Utilities for Java EE (new in Java EE 7)

Concurrency Utilities for Java EE is an API that provides asynchronous capabilities to Java EE application components.

6.21 Batch Applications for the Java Platform (new in Java EE 7)

Batch jobs are tasks that can be executed in background, without human supervision.

The Batch Applications for the Java Platform specification is a framework that provides support for handling batch jobs in Java applications.

7 Java Standard Edition 7 APIs for the Java EE platform

Java EE 7 applications require Java Standard Edition (Java SE 7) APIs

  • Java EE includes Java SE and make the Java SE available to Java EE applications
7.1 Java Database Connectivity API

The Database Connectivity (JDBC) API allows the invocation of SQL commands in Java code

7.2 Java Naming and Directory Interface API

The Java Naming and Directory Interface (JNDI) API enables applications to access multiple naming and directory services, such as LDAP, DNS and NIS.

  • With JNDI, Java applications can store and retrieve any type of Java object

JNDI naming environment

  • JNDI provide components (applications clients, enterprise beans and web components) with access to a JNDI naming environment
  • the naming environment allows a component to be customized without the need to change the component's source code
  • the container implements the component's JNDI environment and the component has access to its JNDI environment as a naming context

Naming Environment Namespaces

  • The naming environment has four logical namespaces:
    • java:comp for objects available to a component
    • java:module for objects available to a module
    • java:app for objects available to a single application
    • java:global for objects shared by all deployed applications

a component can access user-defined or system-provided JNDI named objects

  • system-provided objects names such as default JDBC DataSource object, default JMS connection factory and JTA UserTransaction object are stored in the java:comp namespace
  • user-defined objects are: enterprise beans, JDBC DataSource objects and JMS destination.

A Java EE component locates its environment naming context using the JNDI interfaces: a component creates an InitialContext object and look up the JNDI context under the java:comp/env name.

7.3 JavaBeans Activation Framework

The JavaBeans Activation Framework (JAF) is used by the JavaMail API

7.4 Java API for XML Processing

The Java API for XML Processing (JAXP) supports the SAX and DOM standards for parsing XML documents and can convert XML data using the XSLT standard

7.5 Java Architecture for XML Binding (JAXB)

The Java Architecture for XML Binding binds an XML schema to a representation in Java language

7.6 Java API for XML Web Services (JAX-WS)

The Java API for XML Web Services provides support for web services. The JAX-WS specification supports the implementation of web service endpoints and web service clients.

The JAX-WS specification supports the use of message handlers for processing message requests and responses

7.7 SOAP with Attachments API for Java (SAAJ)

The SOAP with Attachments API for Java is API that enables JAX-WS services to produce and consume SOAP messages.

7.8 Java Authentication and Authorization Service (JAAS)

Authentication is the process of identifying a user or an application and validating their credentials. This means verifying that the user is who it claims to be. For example, a user to be authenticate provides its credentials in the form of a username and a password.

Once the user has been authenticated it must be authorized. Authorization is the process of determining which resources an authenticated user is permitted to access. The simplest way to implement authorization is using an access control list. The access control list assigns users to permission to access a resource.

The Java Authentication and Authorization Service enables Java EE applications to authenticate users and groups to make sure they have the permissions required to execute the Java code

7.9 Common Annotations for the Java Platform, JSR 250 (since Java SE 6)

Annotations enable a declarative programming style in Java

No comments :

Post a Comment