Saturday, June 29, 2013

Java EE7 and Its Evaluatioon


After more than three years with JEE 6 , The latest iteration of java enterprise edition has landed, this version includes improvements and tweaks in different areas of Java EE, specially this version includes introduction of HTML 5. As java developers , we will able to more focus on writing our business logic than writing boilerplate code, have better support for the latest Web applications and frameworks, and gain access to enhanced scalability and richer, simpler functionality. New Java EE 7 will
benefit from new features that enable portable batch processing and improved scalability.

Evolution of Java Enterprise Platform
Over 15 years, Java enterprise platform has changed the world on enterprise  solution implementation and developers around the world  has committed to keep the momentum going.



1998 - 2004
Java EE evolved as enterprise application development platform , and main focus was on robustness and ease of development which extended to facilitate multitier server centric applications development, deployments and maintenance.


Features 
  •   Servlet and JSP
  •  EJB , CMP , RMI/IIOP
  •  Java Connector Architecture
  •  Web Services


2005 - 2012

The focus  shifted to increase developer efficiency and introduction of light weight frameworks like Web Profile as subset of  Java EE specification.

Features 
  •    Introduction of annotation.
  •    EJB 3 business component development model
  •    Persistence API
  •    RESTFull Web Services
  •    Web Profile and Managed beans


2013 - Future       
                                  
With increase demand of enterprise solution to be simplified and reusable , next level of Java EE will be moved into cloud (PaaS)support. Java EE8 will be mainly focus on cloud support  and etc.

Features 
  •    HTML 5 support
  •    Java API for Web Socket
  •            Batch Processing support for Java
  •            Concurrency utilities
  •     Native Jason support


Theme of JEE 7
There are 3 major themes of Java EE 7 as shown below.





Delivering HTML5 dynamic, scalable applications
  •    Reduce response time with low latency data exchange using WebSockets
  •    Simplify data parsing for portable applications with standard JSON support
  •    Deliver asynchronous, scalable, high performance RESTful Services and Async Servlets


Increasing developer productivity through simplification and new container services
  •    Simplify application architecture with a cohesive integrated platform
  •    Increase efficiency with reduced boiler-plate code and broader use of annotations
  •    Enhance application portability with standard RESTful web service client support


And meeting the additional demands of the enterprise by adding new enterprise technologies.
  •    Break down batch jobs into manageable chunks for uninterrupted OLTP performance
  •           Easily define multithreaded concurrent tasks for improved scalability
  •    Deliver transactional applications with choice and flexibility

Major 4 features in Java EE 7

1. HTML5 , Web Socket and Client/Server endpoints


  • Java EE7 is mainly focused on HTML5 and its improvements to the spec,  which allows to develop multimedia enriched web applications , support will be via Web Socket and JSON.
  •  Web Socket is a way of two way communication with web app and the remote server in HTTP fashion with bidirectional full-duplex TCP connection.
  •  Annotation makes everything simple
                                @ServerEndpoint  - convert your POJO class to be web socket server
                  @ClientEndpoint  -  convert your POJO  class to be client socket end point.



@ServerEndpoint(value="/websocket")
public class MyEndpoint {

static  List<Session>  clientList = New ArrayList<Session>();
@OnOpen
public void onOpen(Session session){
            clientList.add(session);
}

@OnClose
public void onClose(Session session){
            clientList.remove(sesion);
}
      

      
 @OnMessage
    public String echoText(String name) {
        return name;
    }
    @OnMessage
    public void myPublishMethod(String message) {
        // send message to all connected clients..
          for(Session client : clientList){
            cleint.getRemote().sendObejct(message);
           
            }    

    }

@ClientEndpoint
public class MyClient {
    @OnOpen
    public void onOpen(Session session) {
           System.out.println("Connected to endpoint: " + session.getBasicRemote());
            String name = "Client1";
            System.out.println("Sending message to endpoint: " + name);
            session.getBasicRemote().sendText(name);
    }
        @OnMessage
    public void processMessage(String message) {
        System.out.println("Received message in client: " + message);
    }


2. JSON Processing
Java EE 7 adds new set of APIs to parsing and generation of JASON text and objects, APIs comes in two forms.
  •    Streaming API

o   Low level , highly efficient event driven API for parsing and generating JSON text. Similar to StAX API in XML.
o   If you need to read part of JSON text , better this method than Object Model.
  •    Object Model API

o   Simple and high level API
o   Similar to DOM API in XML  , loads entire JASON text into memory and allows cross referencing of the objects.

3. Concurrency Utilities

An extension to the Java SE concurrency utilities, and provide proper container managed runtime context for execution of tasks. These utilities provide lower level control and configuration over existing asynch API offered by EJB , servlet or JAX-RS. This gives advantages for programmers to write code for parallel processing, and  remove head ache of low level threads handling.

Provided 4 types of managed objects as below

-ManagedExecutorService
-ManagedScheduledExecutorService
-ManagedThreadFactory
-ConextService



Sample using ManagedExecutorService :

public class MyTaskExecutor  {
            @Resource (name="java:comp/DefaultManagedExecutorService")
            ManagedExecutorService executor;
            Future future = executor.submit(new MyTask ())
}

public class MyTask implements Runnable {
            public void run(){
            //generate statemets...
            }
}



4. Batch Processing Support

Batch processing enables scheduling execution jobs within the JEE container , so no need to depend on third party  frameworks like quartz any more. The long running tasks , background or batch processing capabilities will be helpful to execute tasks like bank statement generation at EOD.
A sample batch processing of  ETL(Extract , Transform , Load) nature can be explain as below. 


 The job consists of a chunked ( Reader , Processor , Writer ) of steps, meta data about the Job is stored in "JobRepository" and "JobOperator" will launch the Job from store.

The entire Job processing is wired using JSL ( Job Specification Language ) in XML format.

<step id="sendStatment">
<chunk>
            <reader ref="accountReaderClassaName"/>
            <processor ref="accountProcessorClassName"/>
            <writer ref="emailWriterClassName"/>
</chunk>
</step>

@Name("accountReaderClassaName")
public class MyReader implements ItemReader {
 ...........
}
@Name ("accountProcessorClassName ")
public class MyProcessor implements ItemProcessor {
 ...........
}

@Name("emailWriterClassName ")
public class MyWriter implements ItemWriter {
 ...........
}


Java EE 7  Spec at Glance.

Java EE 7 is based on the JSR 342 ( http://www.jcp.org/en/jsr/detail?id=342 ) and consists of  34 specs as shown below.


Newly introduced with JEE7


  • 352: Batch Applications for the Java Platform 1.0
  • 353: Java API for JSON Processing 1.0
  • 356: Java API for WebSocket 1.0
  • 236: Concurrency Utilities for Java EE 1.0

Enhancement from prevouse version 

  • 342: Java EE 7 Platform
  • 338: Java API for RESTful Web Services 2.0
  • 339: Java Persistence API 2.1
  • 340: Servlet 3.1
  • 341: Expression Language 3.0
  • 343: Java Message Service 2.0
  • 344: JavaServer Faces 2.2
  • 345: Enteprise JavaBeans 3.2
  • 346: Contexts and Dependency Injection 1.1
  • 349: Bean Validation 1.1

In Maintenance mode


  • 250: Common Annotations 1.2
  • 322: Connector Architecture 1.7
  • 907: Java Transaction API 1.2
  • 196: Java Authentication Services for Provider Interface for Containers
  • 115: Java Authorization for Contract for Containers
  • 919: JavaMail 1.5
  • 318: Interceptors 1.2
  • 109: Web Services 1.4
  • 245: JavaServer Pages 2.3

Resources...

-- World first Java EE 7 supported App Server - GlassFish 4  https://glassfish.java.net/download.html GlassFish Server Open Source Edition 4.0 is a compatible, production implementation of the Java EE 7 platform specification built using an open source license. 

As with Java EE 5 and 6, the Reference Implementation (RI) of Java EE 7 is derived from Project GlassFish. As the RI, GlassFish Server is always up to date with the latest Java EE specifications.

-- Eclipse 4.3  support for JEE7  http://www.eclipse.org/kepler/


-- NetBeans IDE  7.3.1 provide tools, templates, and samples for building Java EE 7 applications. 



No comments:

Post a Comment