SlideShare a Scribd company logo
1 of 129
JAVA, MOVING FORWARD
     JavaSE8 & JavaEE7




                 Copyright © 2012 Akira Koyasu. Some rights reserved.
JavaOne Tokyo 2012
           April 4-5




2                  Copyright © 2012 Akira Koyasu. Some rights reserved.
the Coming Technologies




3                Copyright © 2012 Akira Koyasu. Some rights reserved.
the Coming Technologies

     JavaSE8
      Project Jigsaw

      Project Lambda

      HotRockit

      Nashorn



3                      Copyright © 2012 Akira Koyasu. Some rights reserved.
the Coming Technologies

     JavaSE8           JavaEE7
      Project Jigsaw        PaaS

      Project Lambda        JAX-RS 2.0

      HotRockit             JCache

      Nashorn



3                      Copyright © 2012 Akira Koyasu. Some rights reserved.
JavaSE8




     Copyright © 2012 Akira Koyasu. Some rights reserved.
JavaSE Roadmap

                2011                   2012                                        2013

    2011/7/28                     2012 later                           2013 Summer


     JavaSE7                      JavaSE7u6                                   JavaSE8
                                  JRE for MacOSX                                 Jigsaw
                2012/4/27           Auto-update                                 Lambda
                                                                               JavaFX3.0
                  JavaSE7u4                                                    HotRockit
                 JDK for MacOSX                                                 Nashorn
                    JavaFX2.1                  2012/11
                      G1GC
                   JRE default                      JavaSE6
                                               Last public update

5                                                 Copyright © 2012 Akira Koyasu. Some rights reserved.
Themes of JavaSE8
         (from JSR 337)




6                   Copyright © 2012 Akira Koyasu. Some rights reserved.
Themes of JavaSE8
         (from JSR 337)




       Productivity




6                   Copyright © 2012 Akira Koyasu. Some rights reserved.
Themes of JavaSE8
         (from JSR 337)




       Productivity

       Performance



6                   Copyright © 2012 Akira Koyasu. Some rights reserved.
Themes of JavaSE8
         (from JSR 337)




       Productivity

       Performance

       Modularity

6                   Copyright © 2012 Akira Koyasu. Some rights reserved.
JavaSE8


    Project Jigsaw
    Project Lambda
    HotRockit
    Nashorn

7               Copyright © 2012 Akira Koyasu. Some rights reserved.
Project Jigsaw




8           Copyright © 2012 Akira Koyasu. Some rights reserved.
Project Jigsaw



    No more classpath


8              Copyright © 2012 Akira Koyasu. Some rights reserved.
Project Jigsaw



    No more classpath
       Escape from “JAR hell”
       Modular JDK

8                   Copyright © 2012 Akira Koyasu. Some rights reserved.
module-info.java


                                   com.foo

                            com.foo.Main
    module com.foo {}
                              com.foo.Sub

                         com.foo.util.Tool



9                       Copyright © 2012 Akira Koyasu. Some rights reserved.
requires

                                                      com.foo
     module com.foo {                               com.foo.Main
       requires org.bar;
                                                      com.foo.Sub
       requires com.baz;
     }
                                                  com.foo.util.Tool




                           org.bar                            com.baz

10                                   Copyright © 2012 Akira Koyasu. Some rights reserved.
@ version



     module com.foo @ 1.0.0 {
       requires org.bar @ 1.2.0;                             com.foo
       requires com.baz @ 0.8-beta;
     }




                           org.bar                             com.baz

11                                    Copyright © 2012 Akira Koyasu. Some rights reserved.
permits


                                                           com.app

     module com.foo {
       permits com.app;
       requires org.bar;
       requires com.baz;                                    com.foo
     }



                           org.bar                            com.baz

12                                   Copyright © 2012 Akira Koyasu. Some rights reserved.
permits

                           com.other
                                                            com.app

     module com.foo {
       permits com.app;
       requires org.bar;
       requires com.baz;                                     com.foo
     }



                            org.bar                            com.baz

12                                    Copyright © 2012 Akira Koyasu. Some rights reserved.
permits

                           com.other
                                                            com.app

     module com.foo {
       permits com.app;
       requires org.bar;
       requires com.baz;                                     com.foo
     }



                            org.bar                            com.baz

12                                    Copyright © 2012 Akira Koyasu. Some rights reserved.
optional

     module com.foo {
       requires org.bar;
       requires com.baz;
       requires optional org.bar.extra;
     }


                                                          com.foo
               org.bar.extra

                            org.bar                         com.baz

13                                 Copyright © 2012 Akira Koyasu. Some rights reserved.
optional

     module com.foo {
       requires org.bar;
       requires com.baz;
       requires optional org.bar.extra;
     }


                                                          com.foo
               org.bar.extra

                            org.bar                         com.baz

13                                 Copyright © 2012 Akira Koyasu. Some rights reserved.
provides

     module com.app {
       requires com.foo.util;
       requires com.foo.db;
     }                                        com.app

     module com.foo.lib {
       provides com.foo.util;
       provides com.foo.db;                com.foo.lib
     }




                  com.foo.lib.util              com.foo.lib.db

14                               Copyright © 2012 Akira Koyasu. Some rights reserved.
jpkg



     $	 jpkg	 -m	 modules/com.foo	 jmod	 com.foo
     $	 ls
     modules/
     com.foo@1.0.0.jmod
                                                   com.foo



15                             Copyright © 2012 Akira Koyasu. Some rights reserved.
jmod (1)

     $	 jmod	 -L	 mlib	 create
     $	 jmod	 -L	 mlib	 install	 
     	 	 	 	 /path/to/com.foo@*.jmod	 
     	 	 	 	 /path/to/com.app@*.jmod
     $	 jmod	 -L	 mlib	 ls
                                                             com.app
     com.foo@1.0.0
     com.app@0.8-beta
     $	 java	 -L	 mlib	 -m	 com.app                          com.foo

16                                    Copyright © 2012 Akira Koyasu. Some rights reserved.
jmod (2)

     $	 jmod	 add-repo	 http://jig.sfbay
     $	 jmod	 install	 jdk.tools

                                      http://jig.sfbay

                                   jdk.tools@8.0.0.jmod

                                   jdk.jndi@8.0.0.jmod


17                                  Copyright © 2012 Akira Koyasu. Some rights reserved.
JavaSE8


     Project Jigsaw
     Project Lambda
     HotRockit
     Nashorn

18               Copyright © 2012 Akira Koyasu. Some rights reserved.
Project Lambda




19           Copyright © 2012 Akira Koyasu. Some rights reserved.
Project Lambda




19
       !     Copyright © 2012 Akira Koyasu. Some rights reserved.
Project Lambda



          !
19           Copyright © 2012 Akira Koyasu. Some rights reserved.
Project Lambda



                      !
     Easy-to-use Parallel




19                          Copyright © 2012 Akira Koyasu. Some rights reserved.
Project Lambda



                      !
     Easy-to-use Parallel

     Reduce conceptual and syntactic GAP
       between Serial and Parallel expressions

19                          Copyright © 2012 Akira Koyasu. Some rights reserved.
class Student

     public class Student {
     	 private int gradYear;
     	 private double score;
     	
     	 public int getGradYear() {
     	 	 return gradYear;
     	 }
     	 public void setGradYear(int gradYear) {
     	 	 this.gradYear = gradYear;
     	 }
     	 public double getScore() {
     	 	 return score;
     	 }
     	 public void setScore(double score) {
     	 	 this.score = score;
     	 }
     }




20                            Copyright © 2012 Akira Koyasu. Some rights reserved.
Question




21        Copyright © 2012 Akira Koyasu. Some rights reserved.
Question



     Compute the highest score
          of the students
         graduated in 2011

21                 Copyright © 2012 Akira Koyasu. Some rights reserved.
Highest Score
     with External Iteration

      List<Student> students = new ArrayList<>();
      // ...
      double hightestScore = 0.0;
      for (Student s : students) {
      	 if (s.getGradYear() == 2011) {
      	 	 if (s.getScore() > hightestScore) {
      	 	 	 hightestScore = s.getScore();
      	 	 }
      	 }
      }




22                             Copyright © 2012 Akira Koyasu. Some rights reserved.
Highest Score
     with Internal Iteration
     SmartList<Student> students = new SmartList<>();
     // ...
     double hightestScore = students
     	 .filter(new Predicate<Student>() {
     	 	 @Override
     	 	 public boolean eval(Student s) {
     	 	 	 return s.getGradYear() == 2011;
     	 	 }})
     	 .map(new Mapper<Student, Double>() {
     	 	 @Override
     	 	 public Double map(Student s) {
     	 	 	 return s.getScore();
     	 	 }})
     	 .max();



23                               Copyright © 2012 Akira Koyasu. Some rights reserved.
Highest Score
     with Internal Iteration
     SmartList<Student> students = new SmartList<>();
     // ...
     double hightestScore = students
        .filter(new Predicate<Student>() {
     	 	 @Override
     	 	 public boolean eval(Student s) {
     	 	 	 return s.getGradYear() == 2011;
     	 	 }})
     	 .map(new Mapper<Student, Double>() {
     	 	 @Override
     	 	 public Double map(Student s) {
     	 	 	 return s.getScore();
     	 	 }})
     	 .max();



23                               Copyright © 2012 Akira Koyasu. Some rights reserved.
with Lambdas



     List<Student> students = new ArrayList<>();
     // ...
     double hightestScore = students
     	 .filter((Student s) -> s.getGradYear() == 2011)
     	 .map((Student s) -> s.getScore())
     	 .max();




24                               Copyright © 2012 Akira Koyasu. Some rights reserved.
with Lambdas
                                          and Parallelism




     List<Student> students = new ArrayList<>();
     // ...
     double hightestScore = students
     	 .filter((Student s) -> s.getGradYear() == 2011)
     	 .map((Student s) -> s.getScore())
     	 .max();




24                               Copyright © 2012 Akira Koyasu. Some rights reserved.
with Lambdas
                                          and Parallelism




     List<Student> students = new ArrayList<>();
     // ...
     double hightestScore = students.parallel()
     	 .filter((Student s) -> s.getGradYear() == 2011)
     	 .map((Student s) -> s.getScore())
     	 .max();




24                               Copyright © 2012 Akira Koyasu. Some rights reserved.
the Points




25         Copyright © 2012 Akira Koyasu. Some rights reserved.
the Points


     Lambda Expression




25              Copyright © 2012 Akira Koyasu. Some rights reserved.
the Points


     Lambda Expression

     Default Method




25              Copyright © 2012 Akira Koyasu. Some rights reserved.
the Points


     Lambda Expression

     Default Method

     New Interface:
          ParallelIterable
25               Copyright © 2012 Akira Koyasu. Some rights reserved.
Functional Interface




26              Copyright © 2012 Akira Koyasu. Some rights reserved.
Functional Interface

     Functional interface:




26               Copyright © 2012 Akira Koyasu. Some rights reserved.
Functional Interface

        Functional interface:
     Interface with one method




26                 Copyright © 2012 Akira Koyasu. Some rights reserved.
Functional Interface

        Functional interface:
     Interface with one method
         java.util.Comparator<T>
         java.io.FileFilter
         java.lang.Runnable
         java.awt.event.ActionListener
         ...

26                        Copyright © 2012 Akira Koyasu. Some rights reserved.
Lambda Expression

           Lambda Expression
     instantiates a fuctional interface




27                      Copyright © 2012 Akira Koyasu. Some rights reserved.
Lambda Expression

              Lambda Expression
        instantiates a fuctional interface
     Comparator<String> c
       = (String x, String y) -> x.length() - y.length();




27                                 Copyright © 2012 Akira Koyasu. Some rights reserved.
Lambda Expression

              Lambda Expression
        instantiates a fuctional interface
     Comparator<String> c
       = (String x, String y) -> x.length() - y.length();



                    Comparator<String> c = new Comparator<String>() {



            =       	 @Override
                    	 public int compare(String x, String y) {
                    	 	 return x.length() - y.length();
                    	 }};



27                                     Copyright © 2012 Akira Koyasu. Some rights reserved.
Dilemma


     Collections need new methods
              forEach     reduce
              filter       sorted
              map         ...




28                      Copyright © 2012 Akira Koyasu. Some rights reserved.
Dilemma


     Collections need new methods
              forEach     reduce
              filter       sorted
              map         ...


          Compatibility?

28                      Copyright © 2012 Akira Koyasu. Some rights reserved.
Default Method




29           Copyright © 2012 Akira Koyasu. Some rights reserved.
Default Method

           Interface method
     with default implementation




29                   Copyright © 2012 Akira Koyasu. Some rights reserved.
Default Method

                  Interface method
            with default implementation
     public interface Iterable<T> {
     	
        Iteratr<T> iterator();

     	   Iterable<T> filter(Predicate<? super T> predicate) default {
     	   	 return Iterables.filter(this, predicate);
     	   }

     	   void forEach(Block<? super T> block) default {
     	   	 Iterables.forEach(this, block);
     	   }
     	   // ...
     }


29                                        Copyright © 2012 Akira Koyasu. Some rights reserved.
New Interface:
             ParallelIterable
               ParallelIterable has
         the same methods as Iterable,
                except in parallel.
                                             forEach                  reduce
                                             filter                    sorted
                                             map                      ...


                             interface Collection<T> {
     Collection new method       // ...
                                 ParallelIterable<T> parallel();
            parallel()
                             }



30                             Copyright © 2012 Akira Koyasu. Some rights reserved.
Method Reference

     FileFilter filter = new FileFilter() {
         public boolean accept(File f) {
             return f.canRead();
         }
     };




31                         Copyright © 2012 Akira Koyasu. Some rights reserved.
Method Reference

        FileFilter filter = new FileFilter() {
            public boolean accept(File f) {
                return f.canRead();
            }
        };




     FileFilter filter = (File f) -> f.canRead();




31                            Copyright © 2012 Akira Koyasu. Some rights reserved.
Method Reference

        FileFilter filter = new FileFilter() {
            public boolean accept(File f) {
                return f.canRead();
            }
        };




     FileFilter filter = (File f) -> f.canRead();




          FileFilter filter = File#canRead;



31                            Copyright © 2012 Akira Koyasu. Some rights reserved.
Highest Score
            with Lambdas


     List<Student> students = new ArrayList<>();
     // ...
     double hightestScore = students.parallel()
     	 .filter(s -> s.getGradYear() == 2011)
     	 .map(Student#getScore())
     	 .max();




32                            Copyright © 2012 Akira Koyasu. Some rights reserved.
JavaSE8


     Project Jigsaw
     Project Lambda
     HotRockit
     Nashorn

33             Copyright © 2012 Akira Koyasu. Some rights reserved.
Oracle JVMs




34         Copyright © 2012 Akira Koyasu. Some rights reserved.
Oracle JVMs


                             HotSpot
                                   from Sun




34         Copyright © 2012 Akira Koyasu. Some rights reserved.
Oracle JVMs


     JRockit                             HotSpot
      from BEA                                 from Sun




34                     Copyright © 2012 Akira Koyasu. Some rights reserved.
Oracle JVMs


     JRockit                             HotSpot
      from BEA                                 from Sun




34                     Copyright © 2012 Akira Koyasu. Some rights reserved.
Oracle JVMs


     JRockit                               HotSpot
      from BEA                                   from Sun




                   HotRockit


34                       Copyright © 2012 Akira Koyasu. Some rights reserved.
JRockit




35        Copyright © 2012 Akira Koyasu. Some rights reserved.
JRockit

     jcmd

     no Perm-Gen

     Mission Control

     Flight Recorder

     Deterministic GC


35               Copyright © 2012 Akira Koyasu. Some rights reserved.
JRockit

     jcmd

     no Perm-Gen

     Mission Control            (Premium Feature)


     Flight Recorder            (Premium Feature)


     Deterministic GC           (Premium Feature)




35               Copyright © 2012 Akira Koyasu. Some rights reserved.
JavaSE8


     Project Jigsaw
     Project Lambda
     HotRockit
     Nashorn

36               Copyright © 2012 Akira Koyasu. Some rights reserved.
Nashorn


     New JavaScript Engine in JDK8

     Compliance: ECMA-262 Edition 5
       (Latest ECMAScript standard)

     JavaScript & Java call each other


37                     Copyright © 2012 Akira Koyasu. Some rights reserved.
Native on the JVM


                     AST/IR                                 Java
     JavaScript       Abstract Syntax Tree
                  Intermediate Representation             byte code


                  InvokeDynamic
           uses
                  MethodHandle

38                                  Copyright © 2012 Akira Koyasu. Some rights reserved.
JavaEE7




     Copyright © 2012 Akira Koyasu. Some rights reserved.
JavaEE Roadmap

        2009            2010           2011                2012                    2013

     2009/12/10                                                       2013 Q2


       JavaEE6                                                              JavaEE7
      Extensibility                                                       Provisioning
         Profile                2011/2/28                                    Elasticity
        Pruning                                                           Multi-tenancy
                                  Glassfish                                Orchestration
                                  Server 3.1
                                    Clustering                             Glassfish
      Glassfish v3
      JavaEE6 support
                                                                           Server 4
                                                                        JavaEE7 support

40                                            Copyright © 2012 Akira Koyasu. Some rights reserved.
Themes of JavaEE7
          (from JSR 342)




41                   Copyright © 2012 Akira Koyasu. Some rights reserved.
Themes of JavaEE7
          (from JSR 342)




       Cloud
41                   Copyright © 2012 Akira Koyasu. Some rights reserved.
JavaEE7



     PaaS
     JAX-RS 2.0
     JCache


42            Copyright © 2012 Akira Koyasu. Some rights reserved.
Platform as a Service




     the JavaEE7 Platform
           is a Service

43                Copyright © 2012 Akira Koyasu. Some rights reserved.
[IPS]aaS

            IaaS
     Infrastructure as a Service
                                       PaaS
                                    Platform as a Service
                                                                               SaaS
                                                                           Software as a Service




44                                                   Copyright © 2012 Akira Koyasu. Some rights reserved.
[IPS]aaS

            IaaS
     Infrastructure as a Service
                                       PaaS
                                    Platform as a Service
                                                                               SaaS
                                                                           Software as a Service



      Application

     Middleware

               OS

        HW/NW

44                                                   Copyright © 2012 Akira Koyasu. Some rights reserved.
[IPS]aaS

            IaaS
     Infrastructure as a Service
                                       PaaS
                                    Platform as a Service
                                                                               SaaS
                                                                           Software as a Service



      Application                   Application

     Middleware                    Middleware

               OS                          OS

        HW/NW                        HW/NW

44                                                   Copyright © 2012 Akira Koyasu. Some rights reserved.
[IPS]aaS

            IaaS
     Infrastructure as a Service
                                       PaaS
                                    Platform as a Service
                                                                               SaaS
                                                                           Software as a Service



      Application                   Application                          Application

     Middleware                    Middleware                           Middleware

               OS                          OS                                       OS

        HW/NW                        HW/NW                                  HW/NW

44                                                   Copyright © 2012 Akira Koyasu. Some rights reserved.
Key Features




45          Copyright © 2012 Akira Koyasu. Some rights reserved.
Key Features


     Provisioning




45          Copyright © 2012 Akira Koyasu. Some rights reserved.
Key Features


     Provisioning
     Elasticity



45            Copyright © 2012 Akira Koyasu. Some rights reserved.
Key Features


     Provisioning
     Elasticity
     Multi-tenancy

45            Copyright © 2012 Akira Koyasu. Some rights reserved.
Provisioning

              Auto-Provision Services

                                                Application
            Cloud
         Administration
           Service                  Messaging                   LDAP
                                     Service                    Service

                                     Database                Application
     Provision and Initialize         Service                 Container

                                    Application Dependencies



46                              Copyright © 2012 Akira Koyasu. Some rights reserved.
Elasticity

     Dynamic self-adjusting
      SLA driven Elasticity



     Node    Node   Node              Node




47                  Copyright © 2012 Akira Koyasu. Some rights reserved.
Multi-tenancy

     Shared Application, Shared Data Source


       Tenant 1



       Tenant 2       Application                     Data Source



       Tenant 3
                                @TenantId

48                          Copyright © 2012 Akira Koyasu. Some rights reserved.
JavaEE7



     PaaS
     JAX-RS 2.0
     JCache


49            Copyright © 2012 Akira Koyasu. Some rights reserved.
JAX-RS 2.0
                                                                     javax.ws.rs




                   JAX-RS

     Java API for RESTful web services
           version 1.1 is a part of JavaEE6



50                            Copyright © 2012 Akira Koyasu. Some rights reserved.
JAX-RS


     Client                                Server

                                           Resource
                                              A


                                           Resource
                                              B




51                Copyright © 2012 Akira Koyasu. Some rights reserved.
JAX-RS

                GET
     Client     POST                         Server
                PUT
               DELETE                        Resource
                                                A


                                             Resource
                                                B




51                  Copyright © 2012 Akira Koyasu. Some rights reserved.
JAX-RS

                GET
     Client     POST                           Server
                PUT
               DELETE                          Resource
                                                  A


                  text                         Resource
                  json                            B

                  xml
              byte-stream

51                    Copyright © 2012 Akira Koyasu. Some rights reserved.
JAX-RS

                GET
     Client     POST                           Server
                PUT
     Object    DELETE                          Resource
      A                                           A


     Object       text                         Resource
       B          json                            B

                  xml
              byte-stream

51                    Copyright © 2012 Akira Koyasu. Some rights reserved.
Define a Resource 1.1
                           JAX-RS



     http://example.info/company/1234/employee?id=5678




52                              Copyright © 2012 Akira Koyasu. Some rights reserved.
Define a Resource 1.1
                           JAX-RS



     http://example.info/company/1234/employee?id=5678

         @Path("/company/{companyId}")
         public class CompanyResource {
         	 @GET
         	 @Path("/employee")
         	 @Produces(MediaType.TEXT_PLAIN)
         	 public String employee(
         	 	 	 @PathParam("companyId") String companyId,
         	 	 	 @QueryParam("id") String employeeId) {
         	 	 return findEmployee(companyId, employeeId);
         	 }
         	 // ...
         }

52                                  Copyright © 2012 Akira Koyasu. Some rights reserved.
What’s new in JAX-RS 2.0


     Client API                 Improved Conneg

     Filters & Interceptors     Hypermedia

     Asynchrony                 Validation



      JSR-339: Early Draft Review 3 on 07 June, 2012


53                              Copyright © 2012 Akira Koyasu. Some rights reserved.
Client API


     Client client = ClientFactory.newClient();


     String employeeName = client
     	 	 .target("http://../campany/{campanyId}/employee")
     	 	 .pathParam("campanyId", "1234")
     	 	 .queryParam("id", "5678")
     	 	 .request(MediaType.TEXT_PLAIN)
     	 	 .get(String.class);




54                                   Copyright © 2012 Akira Koyasu. Some rights reserved.
Filters




                                          Resource
                                             A




                                          Resource
                                             B


55        Copyright © 2012 Akira Koyasu. Some rights reserved.
Filters
     Request




                                                    Resource
                                                       A




                                                    Resource
                                                       B


55                  Copyright © 2012 Akira Koyasu. Some rights reserved.
Filters
           Request




                                                          Resource
                                                             A
     Response




                                                          Resource
                                                             B


55                        Copyright © 2012 Akira Koyasu. Some rights reserved.
Filters
           Request




                                                          Resource
                                                             A
     Response




                                                          Resource
                                                             B


55                        Copyright © 2012 Akira Koyasu. Some rights reserved.
Filters
           Request




                                                          Resource
                                                             A
     Response




                                                          Resource
                                                             B
     Response


55                        Copyright © 2012 Akira Koyasu. Some rights reserved.
Filters
           Request
                        PreMatchFilter
                       (server side only)
            Filter 1



                                                                            Resource
                                                                               A
     Response




                                                                            Resource
                                                                               B
     Response


55                                          Copyright © 2012 Akira Koyasu. Some rights reserved.
Filters
           Request
                        PreMatchFilter
                       (server side only)
            Filter 1
                                            RequestFilter

                                 Filter 2    Filter 3
                                                                            Resource
                                                                               A
     Response




                                 Filter 2    Filter 3
                                                                            Resource
                                                                               B
     Response


55                                          Copyright © 2012 Akira Koyasu. Some rights reserved.
Filters
           Request
                        PreMatchFilter
                       (server side only)
            Filter 1
                                            RequestFilter

                                 Filter 2     Filter 3
                                                                             Resource
                                                                                A
     Response                    Filter 5     Filter 4

                                            ResponseFilter

                                 Filter 2     Filter 3
                                                                             Resource
                                                                                B
     Response


55                                           Copyright © 2012 Akira Koyasu. Some rights reserved.
Interceptors


                                     @Consumes
                                     ("application/widget+xml")
     MessageBodyReader
         <Widget>
                                                         Resource
                                                            A

                                     @Produces
                                     ("application/widget+xml")



     MessageBodyWriter
         <Widget>


56                       Copyright © 2012 Akira Koyasu. Some rights reserved.
Interceptors
     Request


                                               @Consumes
                                               ("application/widget+xml")
               MessageBodyReader
                   <Widget>
                                                                   Resource
                                                                      A

                                               @Produces
                                               ("application/widget+xml")



               MessageBodyWriter
                   <Widget>


56                                 Copyright © 2012 Akira Koyasu. Some rights reserved.
Interceptors
     Request


                                                @Consumes
                                                ("application/widget+xml")
               MessageBodyReader
                   <Widget>        Widget
                                                                    Resource
                                                                       A

                                                @Produces
                                                ("application/widget+xml")



               MessageBodyWriter
                   <Widget>


56                                  Copyright © 2012 Akira Koyasu. Some rights reserved.
Interceptors
     Request


                                                 @Consumes
                                                 ("application/widget+xml")
               MessageBodyReader
                   <Widget>        Widget
                                                                     Resource
                                                                        A

                                                 @Produces
                                                 ("application/widget+xml")



               MessageBodyWriter
                   <Widget>        Widget


56                                   Copyright © 2012 Akira Koyasu. Some rights reserved.
Interceptors
     Request


                                                  @Consumes
                                                  ("application/widget+xml")
                MessageBodyReader
                    <Widget>        Widget
                                                                      Resource
                                                                         A
     Response
                                                  @Produces
                                                  ("application/widget+xml")



                MessageBodyWriter
                    <Widget>        Widget


56                                    Copyright © 2012 Akira Koyasu. Some rights reserved.
Interceptors
     Request
                ReaderInterceptor
                   <Widget>
                                                    @Consumes
                                                    ("application/widget+xml")
                  MessageBodyReader
                      <Widget>        Widget
                                                                        Resource
                                                                           A
     Response
                WriterInterceptor                   @Produces
                   <Widget>                         ("application/widget+xml")



                  MessageBodyWriter
                      <Widget>        Widget


56                                      Copyright © 2012 Akira Koyasu. Some rights reserved.
Asynchrony (server side)

      Suspend & Resume connections
               javax.ws.rs.core.ExecutionContext
       @Path("/async/longRunning")
       public class MyResource {
         @Context ExecutionContext ctx;

           @GET @Produces("text/plain")
           public void longRunningOp() {
              Executors.newSingleThreadExecutor().submit(new Runnable() {
                   public void run() {
                     executeLongRunningOp();
                     ctx.resume("Hello async world!");
                   }});
              ctx.suspend();
           }
       }


57                                            Copyright © 2012 Akira Koyasu. Some rights reserved.
Asynchrony (client side)

                            AsyncInvoker
      AsyncInvoker async = client
      	   	  .target("http://.../campany/{campanyId}/employee")
      	   	  .pathParam("campanyId", "1234")
      	   	  .queryParam("id", "5678")
      	   	  .request(MediaType.TEXT_PLAIN)
      	   	  .async();

      // Future<Response>
      Future<Response> fresponse = async.get();

      // InvocationCallback<T>
      Future<String> fstring = async.get(new InvocationCallback<String>(){
      	   @Override
      	   public void completed(String response) { /* ... */ }
      	   @Override
      	   public void failed(ClientException error) { /* ... */ }
      });




58                                           Copyright © 2012 Akira Koyasu. Some rights reserved.
JavaEE7



     PaaS
     JAX-RS 2.0
     JCache


59            Copyright © 2012 Akira Koyasu. Some rights reserved.
JCache
                                                      javax.cache




     Standard Caching API




60              Copyright © 2012 Akira Koyasu. Some rights reserved.
JCache
                                                         javax.cache




     Standard Caching API
           Expiration
         Mutual exclusion
            Spooling
          Consistency

60                 Copyright © 2012 Akira Koyasu. Some rights reserved.
Basic Use

     CacheManager cacheManager = Caching.getCacheManager();
     Cache<Integer, String> cache = cacheManager.getCache("example");

     if   (cache == null) {
     	    cache = cacheManager
     	    	 	 .<Integer, String>createCacheBuilder("example")
     	    	 	 .setExpiry(ExpiryType.MODIFIED,
     	    	 	 	 	 new Duration(TimeUnit.SECONDS, 300L))
     	    	 	 .build();
     }

     Integer key = Integer.valueOf(1);
     String value = "val1";
     cache.put(key, value);

     String value2 = cache.get(key);




61                                       Copyright © 2012 Akira Koyasu. Some rights reserved.
Atomic Operation


     cache.getAndRemove(key);

     cache.getAndReplace(key, value2);

     cache.putIfAbsent(key, value);

     cache.replace(key, value);

     cache.replace(key, value, value2);



62                      Copyright © 2012 Akira Koyasu. Some rights reserved.
Annotation

     @CacheDefaults(cacheName="myScheduler")
     public class MyScheduler {
     	
     	 @CachePut
     	 public void create(
     	 	 	 @CacheKeyParam String id,
     	 	 	 @CacheValue Schedule schedule) { /* ... */ }
     	
     	 @CacheResult
     	 public Schedule get(String id) { /* ... */ }
     	
     	 @CacheRemoveEntry
     	 public void remove(String id) { /* ... */ }
     }



63                               Copyright © 2012 Akira Koyasu. Some rights reserved.
Conclusion




      Copyright © 2012 Akira Koyasu. Some rights reserved.
Conclusion




65         Copyright © 2012 Akira Koyasu. Some rights reserved.
Conclusion




     Revolution
         is coming,
      Don’t miss it!
65              Copyright © 2012 Akira Koyasu. Some rights reserved.
JavaOne 2012
        Sept 30-Oct 4




66                Copyright © 2012 Akira Koyasu. Some rights reserved.
Notes




     This work is licensed under the Creative Commons
     Attribution-NonCommercial 3.0 Unported License. To view
     a copy of this license, visit http://creativecommons.org/
     licenses/by-nc/3.0/.




67                                   Copyright © 2012 Akira Koyasu. Some rights reserved.

More Related Content

Similar to Java, Moving Forward

10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 201310 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013Martin Fousek
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesJavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesMert Çalışkan
 
How Scala, Wicket, and Java EE Can Improve Web Development
How Scala, Wicket, and Java EE Can Improve Web DevelopmentHow Scala, Wicket, and Java EE Can Improve Web Development
How Scala, Wicket, and Java EE Can Improve Web DevelopmentBruno Borges
 
Project Jigsaw in JDK9
Project Jigsaw in JDK9Project Jigsaw in JDK9
Project Jigsaw in JDK9Simon Ritter
 
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012EJB 3.2 - Java EE 7 - Java One Hyderabad 2012
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012Jagadish Prasath
 
Project Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To JavaProject Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To JavaC4Media
 
What's new for JavaFX in JDK8 - Weaver
What's new for JavaFX in JDK8 - WeaverWhat's new for JavaFX in JDK8 - Weaver
What's new for JavaFX in JDK8 - WeaverCodemotion
 
Hello, Guava !
Hello, Guava !Hello, Guava !
Hello, Guava !輝 子安
 
What's New in the JVM in Java 8?
What's New in the JVM in Java 8?What's New in the JVM in Java 8?
What's New in the JVM in Java 8?Azul Systems Inc.
 
What's New in the JVM in Java 8?
What's New in the JVM in Java 8?What's New in the JVM in Java 8?
What's New in the JVM in Java 8?Azul Systems, Inc.
 
JDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerJDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerSimon Ritter
 
[English version] JavaFX and Web Integration
[English version] JavaFX and Web Integration[English version] JavaFX and Web Integration
[English version] JavaFX and Web IntegrationKazuchika Sekiya
 
Introduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry PiIntroduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry PiBruno Borges
 
Building Large Java Projects Faster: Multicore javac and Makefile integration
Building Large Java Projects Faster: Multicore javac and Makefile integrationBuilding Large Java Projects Faster: Multicore javac and Makefile integration
Building Large Java Projects Faster: Multicore javac and Makefile integrationFredrik Öhrström
 
BoxGrinder – FOSDEM 2012
BoxGrinder – FOSDEM 2012BoxGrinder – FOSDEM 2012
BoxGrinder – FOSDEM 2012marekgoldmann
 
What's Expected in Java 7
What's Expected in Java 7What's Expected in Java 7
What's Expected in Java 7Gal Marder
 

Similar to Java, Moving Forward (20)

10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 201310 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesJavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
 
JSX
JSXJSX
JSX
 
How Scala, Wicket, and Java EE Can Improve Web Development
How Scala, Wicket, and Java EE Can Improve Web DevelopmentHow Scala, Wicket, and Java EE Can Improve Web Development
How Scala, Wicket, and Java EE Can Improve Web Development
 
Project Jigsaw in JDK9
Project Jigsaw in JDK9Project Jigsaw in JDK9
Project Jigsaw in JDK9
 
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012EJB 3.2 - Java EE 7 - Java One Hyderabad 2012
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012
 
Complete Dojo
Complete DojoComplete Dojo
Complete Dojo
 
Project Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To JavaProject Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To Java
 
What's new for JavaFX in JDK8 - Weaver
What's new for JavaFX in JDK8 - WeaverWhat's new for JavaFX in JDK8 - Weaver
What's new for JavaFX in JDK8 - Weaver
 
Hello, Guava !
Hello, Guava !Hello, Guava !
Hello, Guava !
 
JavaOne Update zur Java Plattform
JavaOne Update zur Java PlattformJavaOne Update zur Java Plattform
JavaOne Update zur Java Plattform
 
Java SE 8
Java SE 8Java SE 8
Java SE 8
 
What's New in the JVM in Java 8?
What's New in the JVM in Java 8?What's New in the JVM in Java 8?
What's New in the JVM in Java 8?
 
What's New in the JVM in Java 8?
What's New in the JVM in Java 8?What's New in the JVM in Java 8?
What's New in the JVM in Java 8?
 
JDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java SmallerJDK 9: Big Changes To Make Java Smaller
JDK 9: Big Changes To Make Java Smaller
 
[English version] JavaFX and Web Integration
[English version] JavaFX and Web Integration[English version] JavaFX and Web Integration
[English version] JavaFX and Web Integration
 
Introduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry PiIntroduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry Pi
 
Building Large Java Projects Faster: Multicore javac and Makefile integration
Building Large Java Projects Faster: Multicore javac and Makefile integrationBuilding Large Java Projects Faster: Multicore javac and Makefile integration
Building Large Java Projects Faster: Multicore javac and Makefile integration
 
BoxGrinder – FOSDEM 2012
BoxGrinder – FOSDEM 2012BoxGrinder – FOSDEM 2012
BoxGrinder – FOSDEM 2012
 
What's Expected in Java 7
What's Expected in Java 7What's Expected in Java 7
What's Expected in Java 7
 

More from 輝 子安

Protractor under the hood
Protractor under the hoodProtractor under the hood
Protractor under the hood輝 子安
 
そろそろLambda(CI/CD編)
そろそろLambda(CI/CD編)そろそろLambda(CI/CD編)
そろそろLambda(CI/CD編)輝 子安
 
Dockerで構成するWebサービス 〜EmotionTechの場合〜
Dockerで構成するWebサービス 〜EmotionTechの場合〜Dockerで構成するWebサービス 〜EmotionTechの場合〜
Dockerで構成するWebサービス 〜EmotionTechの場合〜輝 子安
 
Workshop: Docker on Elastic Beanstalk
Workshop: Docker on Elastic BeanstalkWorkshop: Docker on Elastic Beanstalk
Workshop: Docker on Elastic Beanstalk輝 子安
 
PHP conference 2013 ja report
PHP conference 2013 ja reportPHP conference 2013 ja report
PHP conference 2013 ja report輝 子安
 
JavaOne Guide for the Petite Bourgeoisie
JavaOne Guide for the Petite BourgeoisieJavaOne Guide for the Petite Bourgeoisie
JavaOne Guide for the Petite Bourgeoisie輝 子安
 
Java, Up to Date Sources
Java, Up to Date SourcesJava, Up to Date Sources
Java, Up to Date Sources輝 子安
 
Hello, Guava ! samples
Hello, Guava ! samplesHello, Guava ! samples
Hello, Guava ! samples輝 子安
 
Tokyo Cabinet & Tokyo Tyrant
Tokyo Cabinet & Tokyo TyrantTokyo Cabinet & Tokyo Tyrant
Tokyo Cabinet & Tokyo Tyrant輝 子安
 

More from 輝 子安 (9)

Protractor under the hood
Protractor under the hoodProtractor under the hood
Protractor under the hood
 
そろそろLambda(CI/CD編)
そろそろLambda(CI/CD編)そろそろLambda(CI/CD編)
そろそろLambda(CI/CD編)
 
Dockerで構成するWebサービス 〜EmotionTechの場合〜
Dockerで構成するWebサービス 〜EmotionTechの場合〜Dockerで構成するWebサービス 〜EmotionTechの場合〜
Dockerで構成するWebサービス 〜EmotionTechの場合〜
 
Workshop: Docker on Elastic Beanstalk
Workshop: Docker on Elastic BeanstalkWorkshop: Docker on Elastic Beanstalk
Workshop: Docker on Elastic Beanstalk
 
PHP conference 2013 ja report
PHP conference 2013 ja reportPHP conference 2013 ja report
PHP conference 2013 ja report
 
JavaOne Guide for the Petite Bourgeoisie
JavaOne Guide for the Petite BourgeoisieJavaOne Guide for the Petite Bourgeoisie
JavaOne Guide for the Petite Bourgeoisie
 
Java, Up to Date Sources
Java, Up to Date SourcesJava, Up to Date Sources
Java, Up to Date Sources
 
Hello, Guava ! samples
Hello, Guava ! samplesHello, Guava ! samples
Hello, Guava ! samples
 
Tokyo Cabinet & Tokyo Tyrant
Tokyo Cabinet & Tokyo TyrantTokyo Cabinet & Tokyo Tyrant
Tokyo Cabinet & Tokyo Tyrant
 

Recently uploaded

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 

Recently uploaded (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 

Java, Moving Forward

  • 1. JAVA, MOVING FORWARD JavaSE8 & JavaEE7 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 2. JavaOne Tokyo 2012 April 4-5 2 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 3. the Coming Technologies 3 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 4. the Coming Technologies JavaSE8 Project Jigsaw Project Lambda HotRockit Nashorn 3 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 5. the Coming Technologies JavaSE8 JavaEE7 Project Jigsaw PaaS Project Lambda JAX-RS 2.0 HotRockit JCache Nashorn 3 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 6. JavaSE8 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 7. JavaSE Roadmap 2011 2012 2013 2011/7/28 2012 later 2013 Summer JavaSE7 JavaSE7u6 JavaSE8 JRE for MacOSX Jigsaw 2012/4/27 Auto-update Lambda JavaFX3.0 JavaSE7u4 HotRockit JDK for MacOSX Nashorn JavaFX2.1 2012/11 G1GC JRE default JavaSE6 Last public update 5 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 8. Themes of JavaSE8 (from JSR 337) 6 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 9. Themes of JavaSE8 (from JSR 337) Productivity 6 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 10. Themes of JavaSE8 (from JSR 337) Productivity Performance 6 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 11. Themes of JavaSE8 (from JSR 337) Productivity Performance Modularity 6 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 12. JavaSE8 Project Jigsaw Project Lambda HotRockit Nashorn 7 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 13. Project Jigsaw 8 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 14. Project Jigsaw No more classpath 8 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 15. Project Jigsaw No more classpath Escape from “JAR hell” Modular JDK 8 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 16. module-info.java com.foo com.foo.Main module com.foo {} com.foo.Sub com.foo.util.Tool 9 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 17. requires com.foo module com.foo { com.foo.Main requires org.bar; com.foo.Sub requires com.baz; } com.foo.util.Tool org.bar com.baz 10 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 18. @ version module com.foo @ 1.0.0 { requires org.bar @ 1.2.0; com.foo requires com.baz @ 0.8-beta; } org.bar com.baz 11 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 19. permits com.app module com.foo { permits com.app; requires org.bar; requires com.baz; com.foo } org.bar com.baz 12 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 20. permits com.other com.app module com.foo { permits com.app; requires org.bar; requires com.baz; com.foo } org.bar com.baz 12 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 21. permits com.other com.app module com.foo { permits com.app; requires org.bar; requires com.baz; com.foo } org.bar com.baz 12 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 22. optional module com.foo { requires org.bar; requires com.baz; requires optional org.bar.extra; } com.foo org.bar.extra org.bar com.baz 13 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 23. optional module com.foo { requires org.bar; requires com.baz; requires optional org.bar.extra; } com.foo org.bar.extra org.bar com.baz 13 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 24. provides module com.app { requires com.foo.util; requires com.foo.db; } com.app module com.foo.lib { provides com.foo.util; provides com.foo.db; com.foo.lib } com.foo.lib.util com.foo.lib.db 14 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 25. jpkg $ jpkg -m modules/com.foo jmod com.foo $ ls modules/ com.foo@1.0.0.jmod com.foo 15 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 26. jmod (1) $ jmod -L mlib create $ jmod -L mlib install /path/to/com.foo@*.jmod /path/to/com.app@*.jmod $ jmod -L mlib ls com.app com.foo@1.0.0 com.app@0.8-beta $ java -L mlib -m com.app com.foo 16 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 27. jmod (2) $ jmod add-repo http://jig.sfbay $ jmod install jdk.tools http://jig.sfbay jdk.tools@8.0.0.jmod jdk.jndi@8.0.0.jmod 17 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 28. JavaSE8 Project Jigsaw Project Lambda HotRockit Nashorn 18 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 29. Project Lambda 19 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 30. Project Lambda 19 ! Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 31. Project Lambda ! 19 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 32. Project Lambda ! Easy-to-use Parallel 19 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 33. Project Lambda ! Easy-to-use Parallel Reduce conceptual and syntactic GAP between Serial and Parallel expressions 19 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 34. class Student public class Student { private int gradYear; private double score; public int getGradYear() { return gradYear; } public void setGradYear(int gradYear) { this.gradYear = gradYear; } public double getScore() { return score; } public void setScore(double score) { this.score = score; } } 20 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 35. Question 21 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 36. Question Compute the highest score of the students graduated in 2011 21 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 37. Highest Score with External Iteration List<Student> students = new ArrayList<>(); // ... double hightestScore = 0.0; for (Student s : students) { if (s.getGradYear() == 2011) { if (s.getScore() > hightestScore) { hightestScore = s.getScore(); } } } 22 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 38. Highest Score with Internal Iteration SmartList<Student> students = new SmartList<>(); // ... double hightestScore = students .filter(new Predicate<Student>() { @Override public boolean eval(Student s) { return s.getGradYear() == 2011; }}) .map(new Mapper<Student, Double>() { @Override public Double map(Student s) { return s.getScore(); }}) .max(); 23 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 39. Highest Score with Internal Iteration SmartList<Student> students = new SmartList<>(); // ... double hightestScore = students .filter(new Predicate<Student>() { @Override public boolean eval(Student s) { return s.getGradYear() == 2011; }}) .map(new Mapper<Student, Double>() { @Override public Double map(Student s) { return s.getScore(); }}) .max(); 23 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 40. with Lambdas List<Student> students = new ArrayList<>(); // ... double hightestScore = students .filter((Student s) -> s.getGradYear() == 2011) .map((Student s) -> s.getScore()) .max(); 24 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 41. with Lambdas and Parallelism List<Student> students = new ArrayList<>(); // ... double hightestScore = students .filter((Student s) -> s.getGradYear() == 2011) .map((Student s) -> s.getScore()) .max(); 24 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 42. with Lambdas and Parallelism List<Student> students = new ArrayList<>(); // ... double hightestScore = students.parallel() .filter((Student s) -> s.getGradYear() == 2011) .map((Student s) -> s.getScore()) .max(); 24 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 43. the Points 25 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 44. the Points Lambda Expression 25 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 45. the Points Lambda Expression Default Method 25 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 46. the Points Lambda Expression Default Method New Interface: ParallelIterable 25 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 47. Functional Interface 26 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 48. Functional Interface Functional interface: 26 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 49. Functional Interface Functional interface: Interface with one method 26 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 50. Functional Interface Functional interface: Interface with one method java.util.Comparator<T> java.io.FileFilter java.lang.Runnable java.awt.event.ActionListener ... 26 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 51. Lambda Expression Lambda Expression instantiates a fuctional interface 27 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 52. Lambda Expression Lambda Expression instantiates a fuctional interface Comparator<String> c = (String x, String y) -> x.length() - y.length(); 27 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 53. Lambda Expression Lambda Expression instantiates a fuctional interface Comparator<String> c = (String x, String y) -> x.length() - y.length(); Comparator<String> c = new Comparator<String>() { = @Override public int compare(String x, String y) { return x.length() - y.length(); }}; 27 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 54. Dilemma Collections need new methods forEach reduce filter sorted map ... 28 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 55. Dilemma Collections need new methods forEach reduce filter sorted map ... Compatibility? 28 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 56. Default Method 29 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 57. Default Method Interface method with default implementation 29 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 58. Default Method Interface method with default implementation public interface Iterable<T> { Iteratr<T> iterator(); Iterable<T> filter(Predicate<? super T> predicate) default { return Iterables.filter(this, predicate); } void forEach(Block<? super T> block) default { Iterables.forEach(this, block); } // ... } 29 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 59. New Interface: ParallelIterable ParallelIterable has the same methods as Iterable, except in parallel. forEach reduce filter sorted map ... interface Collection<T> { Collection new method // ... ParallelIterable<T> parallel(); parallel() } 30 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 60. Method Reference FileFilter filter = new FileFilter() { public boolean accept(File f) { return f.canRead(); } }; 31 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 61. Method Reference FileFilter filter = new FileFilter() { public boolean accept(File f) { return f.canRead(); } }; FileFilter filter = (File f) -> f.canRead(); 31 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 62. Method Reference FileFilter filter = new FileFilter() { public boolean accept(File f) { return f.canRead(); } }; FileFilter filter = (File f) -> f.canRead(); FileFilter filter = File#canRead; 31 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 63. Highest Score with Lambdas List<Student> students = new ArrayList<>(); // ... double hightestScore = students.parallel() .filter(s -> s.getGradYear() == 2011) .map(Student#getScore()) .max(); 32 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 64. JavaSE8 Project Jigsaw Project Lambda HotRockit Nashorn 33 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 65. Oracle JVMs 34 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 66. Oracle JVMs HotSpot from Sun 34 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 67. Oracle JVMs JRockit HotSpot from BEA from Sun 34 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 68. Oracle JVMs JRockit HotSpot from BEA from Sun 34 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 69. Oracle JVMs JRockit HotSpot from BEA from Sun HotRockit 34 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 70. JRockit 35 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 71. JRockit jcmd no Perm-Gen Mission Control Flight Recorder Deterministic GC 35 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 72. JRockit jcmd no Perm-Gen Mission Control (Premium Feature) Flight Recorder (Premium Feature) Deterministic GC (Premium Feature) 35 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 73. JavaSE8 Project Jigsaw Project Lambda HotRockit Nashorn 36 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 74. Nashorn New JavaScript Engine in JDK8 Compliance: ECMA-262 Edition 5 (Latest ECMAScript standard) JavaScript & Java call each other 37 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 75. Native on the JVM AST/IR Java JavaScript Abstract Syntax Tree Intermediate Representation byte code InvokeDynamic uses MethodHandle 38 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 76. JavaEE7 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 77. JavaEE Roadmap 2009 2010 2011 2012 2013 2009/12/10 2013 Q2 JavaEE6 JavaEE7 Extensibility Provisioning Profile 2011/2/28 Elasticity Pruning Multi-tenancy Glassfish Orchestration Server 3.1 Clustering Glassfish Glassfish v3 JavaEE6 support Server 4 JavaEE7 support 40 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 78. Themes of JavaEE7 (from JSR 342) 41 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 79. Themes of JavaEE7 (from JSR 342) Cloud 41 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 80. JavaEE7 PaaS JAX-RS 2.0 JCache 42 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 81. Platform as a Service the JavaEE7 Platform is a Service 43 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 82. [IPS]aaS IaaS Infrastructure as a Service PaaS Platform as a Service SaaS Software as a Service 44 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 83. [IPS]aaS IaaS Infrastructure as a Service PaaS Platform as a Service SaaS Software as a Service Application Middleware OS HW/NW 44 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 84. [IPS]aaS IaaS Infrastructure as a Service PaaS Platform as a Service SaaS Software as a Service Application Application Middleware Middleware OS OS HW/NW HW/NW 44 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 85. [IPS]aaS IaaS Infrastructure as a Service PaaS Platform as a Service SaaS Software as a Service Application Application Application Middleware Middleware Middleware OS OS OS HW/NW HW/NW HW/NW 44 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 86. Key Features 45 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 87. Key Features Provisioning 45 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 88. Key Features Provisioning Elasticity 45 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 89. Key Features Provisioning Elasticity Multi-tenancy 45 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 90. Provisioning Auto-Provision Services Application Cloud Administration Service Messaging LDAP Service Service Database Application Provision and Initialize Service Container Application Dependencies 46 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 91. Elasticity Dynamic self-adjusting SLA driven Elasticity Node Node Node Node 47 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 92. Multi-tenancy Shared Application, Shared Data Source Tenant 1 Tenant 2 Application Data Source Tenant 3 @TenantId 48 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 93. JavaEE7 PaaS JAX-RS 2.0 JCache 49 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 94. JAX-RS 2.0 javax.ws.rs JAX-RS Java API for RESTful web services version 1.1 is a part of JavaEE6 50 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 95. JAX-RS Client Server Resource A Resource B 51 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 96. JAX-RS GET Client POST Server PUT DELETE Resource A Resource B 51 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 97. JAX-RS GET Client POST Server PUT DELETE Resource A text Resource json B xml byte-stream 51 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 98. JAX-RS GET Client POST Server PUT Object DELETE Resource A A Object text Resource B json B xml byte-stream 51 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 99. Define a Resource 1.1 JAX-RS http://example.info/company/1234/employee?id=5678 52 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 100. Define a Resource 1.1 JAX-RS http://example.info/company/1234/employee?id=5678 @Path("/company/{companyId}") public class CompanyResource { @GET @Path("/employee") @Produces(MediaType.TEXT_PLAIN) public String employee( @PathParam("companyId") String companyId, @QueryParam("id") String employeeId) { return findEmployee(companyId, employeeId); } // ... } 52 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 101. What’s new in JAX-RS 2.0 Client API Improved Conneg Filters & Interceptors Hypermedia Asynchrony Validation JSR-339: Early Draft Review 3 on 07 June, 2012 53 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 102. Client API Client client = ClientFactory.newClient(); String employeeName = client .target("http://../campany/{campanyId}/employee") .pathParam("campanyId", "1234") .queryParam("id", "5678") .request(MediaType.TEXT_PLAIN) .get(String.class); 54 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 103. Filters Resource A Resource B 55 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 104. Filters Request Resource A Resource B 55 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 105. Filters Request Resource A Response Resource B 55 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 106. Filters Request Resource A Response Resource B 55 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 107. Filters Request Resource A Response Resource B Response 55 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 108. Filters Request PreMatchFilter (server side only) Filter 1 Resource A Response Resource B Response 55 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 109. Filters Request PreMatchFilter (server side only) Filter 1 RequestFilter Filter 2 Filter 3 Resource A Response Filter 2 Filter 3 Resource B Response 55 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 110. Filters Request PreMatchFilter (server side only) Filter 1 RequestFilter Filter 2 Filter 3 Resource A Response Filter 5 Filter 4 ResponseFilter Filter 2 Filter 3 Resource B Response 55 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 111. Interceptors @Consumes ("application/widget+xml") MessageBodyReader <Widget> Resource A @Produces ("application/widget+xml") MessageBodyWriter <Widget> 56 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 112. Interceptors Request @Consumes ("application/widget+xml") MessageBodyReader <Widget> Resource A @Produces ("application/widget+xml") MessageBodyWriter <Widget> 56 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 113. Interceptors Request @Consumes ("application/widget+xml") MessageBodyReader <Widget> Widget Resource A @Produces ("application/widget+xml") MessageBodyWriter <Widget> 56 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 114. Interceptors Request @Consumes ("application/widget+xml") MessageBodyReader <Widget> Widget Resource A @Produces ("application/widget+xml") MessageBodyWriter <Widget> Widget 56 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 115. Interceptors Request @Consumes ("application/widget+xml") MessageBodyReader <Widget> Widget Resource A Response @Produces ("application/widget+xml") MessageBodyWriter <Widget> Widget 56 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 116. Interceptors Request ReaderInterceptor <Widget> @Consumes ("application/widget+xml") MessageBodyReader <Widget> Widget Resource A Response WriterInterceptor @Produces <Widget> ("application/widget+xml") MessageBodyWriter <Widget> Widget 56 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 117. Asynchrony (server side) Suspend & Resume connections javax.ws.rs.core.ExecutionContext @Path("/async/longRunning") public class MyResource { @Context ExecutionContext ctx; @GET @Produces("text/plain") public void longRunningOp() { Executors.newSingleThreadExecutor().submit(new Runnable() { public void run() { executeLongRunningOp(); ctx.resume("Hello async world!"); }}); ctx.suspend(); } } 57 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 118. Asynchrony (client side) AsyncInvoker AsyncInvoker async = client .target("http://.../campany/{campanyId}/employee") .pathParam("campanyId", "1234") .queryParam("id", "5678") .request(MediaType.TEXT_PLAIN) .async(); // Future<Response> Future<Response> fresponse = async.get(); // InvocationCallback<T> Future<String> fstring = async.get(new InvocationCallback<String>(){ @Override public void completed(String response) { /* ... */ } @Override public void failed(ClientException error) { /* ... */ } }); 58 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 119. JavaEE7 PaaS JAX-RS 2.0 JCache 59 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 120. JCache javax.cache Standard Caching API 60 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 121. JCache javax.cache Standard Caching API Expiration Mutual exclusion Spooling Consistency 60 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 122. Basic Use CacheManager cacheManager = Caching.getCacheManager(); Cache<Integer, String> cache = cacheManager.getCache("example"); if (cache == null) { cache = cacheManager .<Integer, String>createCacheBuilder("example") .setExpiry(ExpiryType.MODIFIED, new Duration(TimeUnit.SECONDS, 300L)) .build(); } Integer key = Integer.valueOf(1); String value = "val1"; cache.put(key, value); String value2 = cache.get(key); 61 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 123. Atomic Operation cache.getAndRemove(key); cache.getAndReplace(key, value2); cache.putIfAbsent(key, value); cache.replace(key, value); cache.replace(key, value, value2); 62 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 124. Annotation @CacheDefaults(cacheName="myScheduler") public class MyScheduler { @CachePut public void create( @CacheKeyParam String id, @CacheValue Schedule schedule) { /* ... */ } @CacheResult public Schedule get(String id) { /* ... */ } @CacheRemoveEntry public void remove(String id) { /* ... */ } } 63 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 125. Conclusion Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 126. Conclusion 65 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 127. Conclusion Revolution is coming, Don’t miss it! 65 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 128. JavaOne 2012 Sept 30-Oct 4 66 Copyright © 2012 Akira Koyasu. Some rights reserved.
  • 129. Notes This work is licensed under the Creative Commons Attribution-NonCommercial 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/ licenses/by-nc/3.0/. 67 Copyright © 2012 Akira Koyasu. Some rights reserved.

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n
  114. \n
  115. \n
  116. \n
  117. \n
  118. \n
  119. \n
  120. \n
  121. \n
  122. \n
  123. \n
  124. \n
  125. \n
  126. \n