J2EE Design Pattern – Context Object

Problem

Avoid Protocol-specific outsides its context

Solution

A context object encapsulate protocol-specific  information.

Example

Spring

  • ApplicationContext (Per Application)
  • SecurityContext (Per Request)

Java Server Face

  • FacesContext (Per Request)

Servlet

  • ServletContext

WildFly – Standard J2EE

  • Java API for RESTful Web Services (JAX-RS)
  • Java Servlet Technology
  • Java Server Faces Technology (JSF)
  • Java Persistence API (JPA)
  • Java Transaction API (JTA)
  • Managed Beans
  • Contexts and Dependency Injection (CDI)
  • Bean Validation
  • Java Message Service API (JMS)
  • JavaEE Connector Architecture (JCA)
  • JavaMail API
  • Java Authorization Contract for Containers (JACC)
  • Java Authentication Service Provider Interface for Containers (JASPIC)
  • Enterprise JavaBeans Technology (EJB)
  • Java API for XML Web Services (JAX-WS)

web.xml Template

 

<web-app id="WebApp_ID" version="2.4"
 xmlns="http://java.sun.com/xml/ns/j2ee" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 
 <display-name>Spring MVC Application</display-name>

 <servlet>
 <servlet-name>HelloWeb</servlet-name>
 <servlet-class>
 org.springframework.web.servlet.DispatcherServlet
 </servlet-class>
 <load-on-startup>1</load-on-startup>
 </servlet>

 <servlet-mapping>
 <servlet-name>HelloWeb</servlet-name>
 <url-pattern>*.jsp</url-pattern>
 </servlet-mapping>

</web-app>

 

 

Web Service Example with JBoss

IDE: Eclipse

Application Server: JBoss 7.1

Testing Tools: SoapUI 5.2.1

Steps: 

  1. Create a J2EE Web Project: Name: HelloWorld
  2. Create a Java Class named: Hello. The Code is in the below
  3. Run in Server

Test Steps

  1. Visit http://localhost:8080/HelloWorld/Hello?wsdl

Image 001

  1.  Use Soap UI to call web service

這個slideshow需要JavaScript。

 

 

Source Code

import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public class Hello {
 @WebMethod
 public void print(){
 System.out.println("Hello");
 }
}

 

 

Websphere Overview

WebSphere Application Server

  • Family Editions
    • WAS Network Deployment
    • WAS
    • WAS Liberty Core

Liberty Profile

It is new capacity since 8.5. It is lightweight profile for web, mobile, OSGi applications.

Profiles

Websphere Application Server can obtain various profiles for different purpose. Each profile have unique config for the run-time environment.

Image 020

Node and Cell

Cell is deployment unit for a profile. A cell can contain one or more nodes for deployment.

 

  •  Wasadmin

Reference

J2EE API

Relationship among the J2EE Containers.

Diagram of Java EE containers

API Summary

  • Enterprise JavaBeans Technology
  • Servlet Technology
  • Java Server Face Technology
  • JavaServer Pages Technology
  • JavaServer Pages Standard Tag Library
  • Java Persistence API
  • Java Transaction API
  • Java API for RESTful Web Services
  • Managed Beans
  • Contexts and Dependency Injection for the Java EE Platform (JSR 299)
  • Dependency Injection for Java (JSR 330)
  • Bean Validation
  • Java Message Service API
  • Java EE Connector Architecture
  • JavaMail API
  • Java Authorization Contract for Containers
  • Java Authentication Service Provider Interface for Containers
  • Java Database Connectivity API
  • Java Naming and Directory Interface API
  • JavaBeans Activation Framework
  • Java API for XML Processing
  • Java Architecture for XML Binding
  • SOAP with Attachments API for Java
  • Java API for XML Web Services
  • Java Authentication and Authorization Service

 

Diagram of Java EE APIs in the web containerDiagram of Java EE APIs in the EJB container

Diagram of Java EE APIs in the application client container

JSR 229: Payment API
JSR 330: Dependency Injection for Java
JSR 299: Contexts and Dependency Injection for the JavaTM EE platform