Term | Definition |
---|---|
Java EE (JEE) | Java Platform, Enterprise Edition |
JCP | Java Community Process |
JSRs | Java Specification Requests |
POJOs | Plain Old Java Objects |
JSP | JavaServer Page |
EJB | Enterprise JavaBeans |
XML | Extensible Markup Language |
SOAP | Simple Object Access Protocol |
WSDL | Web Service Description Language |
JAR | Java Archive file |
WAR | Web Archive file |
EAR | Enterprise Archive file |
JSP | JavaServer Pages |
JSTL | JavaServer Pages Standard Tag Library |
JPA | Java Persistence API |
JTA | Java Transaction API |
JAX-RS | Java API for RESTful Web Services |
JMS | Java Message Service |
JACC | Java Authorization Contract for Containers |
JASPIC | Java Authentication Service Provider Interface for Containers |
JAF | JavaBeans Activation Framework |
JAXP | Java API for XML Processing |
JAXB | Java API for XML Binding |
SAAJ | SOAP with Attachments API for Java |
JAX-WS | Java API for XML Web Services |
JAAS | Java Authentication and Authorization |
JPDA | Java Platform Debugger Architecture |
UDDI | Universal Description, Discovery and Integration |
SOAP | Simple Object Access Protocol |
SEI | Service Endpoint Interface |
- Web Service: produce data that can be consume by web application. Web Service can communicate with each other. It faces to server.
- Web Application: consume data from web server and interact with users. It faces to user.
Define a contract associated with a web service that used by other web services to communicate with it.
- Like an interface between different Java modules.
- Written in XML format.
- definitions:
- types:
- message:
- portType:
- operation:
- input:
- output:
- operation:
- binding:
- service:
- port:
Service
/ \
Port Binding -> Port Type
|
Operations
/ \
Input Message Output Message
-
An abstract WSDL document describes what the web service does, but not how it does it or how to contact it. An abstract WSDL document defines:
- the operations provided by the web service.
- the input, output and fault messages used by each operation to communicate with the web service, and their format.
-
A concrete WSDL document adds the information about how the web service communicates and where you can reach it. A concrete WSDL document contains the abstract WSDL definitions, and also defines:
- the communication protocols and data encodings used by the web service.
- the port address that must be used to contact the web service.
Cover Java object to SOAP massage.
JEE uses a distributed multitiered application model for enterprise applications. Generally, it can be divided into tiers in following list:
- Client-tier components run on the client machine. (Web Pages)
- Web-tier components run on the Java EE server. (JavaServer Page)
- Business-tier components run on the Java EE server. (Enterprise Beans)
- Enterprise information system (EIS)-tier software runs on the EIS server. (Database)
Containers are the interface between a component and the low-level platform-specific functionality that supports the component.
- Java EE server: The runtime portion of a Java EE product, which provides EJB and web containers.
- EJB container: Manages the execution of enterprise beans.
- Web container: Manages the execution of web pages, servlets, and some EJB components.
- Application client container: Manages the execution of application client components.
- Applet container: Manages the execution of applets. Consists of a web browser and Java Plug-in running on the client together.
EJB is a body of code having fields and methods to implement modules of business logic.
- session bean: a transient conversation with a client. When the client finishes executing, the session bean and its data are gone.
- message-driven bean: combines features of a session bean and a message listener, allowing a business component to receive messages asynchronously.
A servlet class extends the capabilities of servers that host applications accessed by way of a request-resoponse programming model.
JSP lets us put snippets of servlet code directly into a text-based document (HTML or XML).
JSTL encapsulates core functionality common to many JSP applications.
JTA provides a standard interface for demarcating transactions.
The Bean Validation specification defines a metadata model and API for validating data in JavaBeans components.
HTTP Request
Web Client --------------> HttpServlet
^ |
| HTTP Response |
---------------------- Web Components --> Database
|
|
JavaBeans Components --> Database
A web application consists of web components; static resource files, such as images; and helper classes and libraries.
- Develop the web component code.
- Develop the web application deployment descriptor, if necessary.
- Compile the web application components and helper classes referenced by the components.
- Optionally, package the application into a deployable unit.
- Deploy the application into a web container.
- Access a URL that references the web application.
A web serve uses HTTP protocal to transfer data.
- Apache Tomcat
- JBoss
Servlet container is the container for Servlets that manages the life cycle of each servlet.
Servlet is an interface defined in javax.servlet
package.
Servlet can only has one instance and by default, it is lazy loaded: Server will only instantiate each servlet once and only once when there is a request for that servlet.
Using servlets allows the JVM to handle each request within a separate Java thread, and this is one of the key advantage of Servlet container.
Note: we can force it to be loaded when server start by setting <load-on-startup>
to 1.
Servlet inferface declares three essential methods of the life cycle of a servlet
void init(ServletConfig)
: it is invoked during initialization stage. It is passed an object implementing thejavax.servlet.ServletConfig
interface, which allows the servlet to access initialization parameters from the web application.void service(ServletRequest, ServletResponse)
: it is invoked upon each request after its initialization. Each request is serviced in its own separate thread. The web container calls the service() method of the servlet for every request. The service() method determines the kind of request being made and dispatches it to an appropriate method to handle the request.void destroy()
: it is invoked when the servlet object should be destroyed. It releases the resources being held.
- Web server recevies HTTP request
- Web server forwards the request to servlet container within JVM
- The servlet is dynamically retrieved and loaded into the address space of the container, if it is not in the container.
- The container invokes the init() method of the servlet for initialization (invoked once when the servlet is loaded first time)
- The container invokes the service() method of the servlet to process the HTTP request, i.e., read data in the request and formulate a response. The servlet remains in the container’s address space and can process other HTTP requests.
- Web server return the dynamically generated results to the correct location