KEMBAR78
Java EE 與 雲端運算的展望 | PDF
Java EE 7
Reaching for the Cloud
Lee Chuk Munn
chuk-munn.lee@oracle.com
The following is intended to outline our general
product direction. It is intended for information
purposes only, and may not be incorporated
into any contract. It is not a commitment to
deliver any material, code, or functionality, and
should not be relied upon in making purchasing
decisions.

The development, release, and timing of any
features or functionality described for Oracle's
products remains at the sole discretion of
Oracle.
Java EE 6 Platform
December 10, 2009
Great Tooling Support
Industry Wide Support
<Insert Picture Here>




Java EE 6
What is New in Java EE 6?
• Several new APIs
• Web profile
• Pluggability/extensibility
• Dependency injection
• Lots of improvements to existing API
New And Updated Components
• EJB 3.1 (+Lite)       • Managed Beans 1.0
• JPA 2.0               • Interceptors 1.1
• Servlet 3.0           • JSP 2.2
• JSF 2.0               • EL 2.2
• JAX-RS 1.1            • JSR-250 1.1
• Bean Validation 1.0   • JASPIC 1.1
• DI 1.0                • JACC 1.5
• CDI 1.0               • JAX-WS 2.2
• Connectors 1.6        • JSR-109 1.3
Java EE 6 Web Profile

             Web container                           JSP 2.2
              extensions
                                 JSF 2.0            JSTL 1.2
   CDI




                                                               Bean Validation 1.0
extensions
                             Servlet 3.0 · EL 2.2

    DI 1.0 · CDI 1.0 · Interceptors 1.1 · JSR-250 1.1

    Managed Beans 1.0                      EJB 3.1 Lite

                        JPA 2.0 · JTA 1.1
Web Tier Updates
• Annotations in Servlet 3.0
• Automatic discovery and registration of libraries
• web.xml is optional
• Package static files in resource jars
• Use EJBs directly inside web apps
Web Apps Simplified Packaging
    Web Application
WEB-INF/classes
 com/acme/MyServlet.class
 com/acme/MyFilter.class
WEB-INF/lib
 someframework.jar
WEB-INF/web.xml


index.html
main.css
jquery-1.4.2.js
ui/jquery.ui.core.js
ui/jquery.ui.widget.js
Web Apps Simplified Packaging
    Web Application
WEB-INF/classes             @WebServlet(urlPatterns=”/foo”)
 com/acme/MyServlet.class   public class MyServlet { … }
 com/acme/MyFilter.class
WEB-INF/lib                 @WebFilter(urlPatterns=”/foo”)
 someframework.jar          public class MyFilter { … }
WEB-INF/web.xml


index.html
main.css
jquery-1.4.2.js
ui/jquery.ui.core.js
ui/jquery.ui.widget.js
Web Apps Simplified Packaging
    Web Application
WEB-INF/classes
 com/acme/MyServlet.class
 com/acme/MyFilter.class     Framework Jar
WEB-INF/lib              META-INF/web-fragment.xml
 someframework.jar       com/fw/FwServlet.class
                         com/fw/FwFilter.class


index.html
main.css
jquery-1.4.2.js
ui/jquery.ui.core.js
ui/jquery.ui.widget.js
Web Apps Simplified Packaging
   Web Application
WEB-INF/classes
 com/acme/MyServlet.class
 com/acme/MyFilter.class
WEB-INF/lib
 someframework.jar
                             jQuery Resource Jar
 jquery-ui-1.8.4.jar    META-INF/resources/jquery-1.4.2.js
                        META-INF/resources/ui/jquery.ui.core.js
                        META-INF/resources/ui/jquery.ui.widget.js
index.html
main.css
Web Apps Simplified Packaging
   Web Application          • Self-contained

WEB-INF/classes             • Generic
 com/acme/MyServlet.class   • Reusable
 com/acme/MyFilter.class
WEB-INF/lib
 someframework.jar
 jquery-ui-1.8.4.jar



index.html
main.css
Java EE 6 Programming Model
• Complementary declarative/programmatic layer
• Annotations are additive
• Code can evolve gradually
• Managed beans as a common foundation
EJB 3.1 Lite
• Session bean programming model
• Stateless, singleton programming model
• Annotation based declarative security and
  transactions
• Deployment descriptors are optional
EJB 3.1 New First Class Construct
@Singleton @Startup
public class StartupBean {
 @PostConstruct
 public void doAtStartup() { … }
}

@Stateless public class BackupBean {
 @Schedule(dayOfWeek=”Fri”, hour=”3”, minute=”15”)
 public void performBackup() { … }
}

@Stateless public class BatchProcessor {
 @Asynchronous public Future<Result> submit(Task t){ … }
}
Dependency Injection
• Powerful type-safe model
• Can be enabled per-module
• Integrated with JSF, JSP, EJB, web tier
• Friendly to pre-Java EE 6 resources and services
• Event model
• Highly extensible
Bean with Constructor Injection

@RequestScoped
public class CheckoutHandler {
  @Inject
  public CheckoutHandler(
            @LoggedIn User user,
            @Reliable @PayBy(CREDIT_CARD)
            PaymentProcessor processor,
            @Default ShoppingCart cart) {…}
Bean with Constructor Injection

 @RequestScoped
 public class CheckoutHandler {
   @Inject
   public CheckoutHandler(
             @LoggedIn User user,
             @Reliable @PayBy(CREDIT_CARD)
Types
             PaymentProcessor processor,
             @Default ShoppingCart cart) {…}
Bean with Constructor Injection

  @RequestScoped
  public class CheckoutHandler {
      @Inject
      public CheckoutHandler(
               @LoggedIn User user,
               @Reliable @PayBy(CREDIT_CARD)
Qualifiers
               PaymentProcessor processor,
               @Default ShoppingCart cart) {…}
Bean with Constructor Injection
                               Request scoped
@RequestScoped
public class CheckoutHandler {
  @Inject
  public CheckoutHandler(
            @LoggedIn User user,
            @Reliable @PayBy(CREDIT_CARD)
            PaymentProcessor processor,
            @Default ShoppingCart cart) {…}
Bean with Constructor Injection

  @RequestScoped
  public class CheckoutHandler {
      @Inject
      public CheckoutHandler(
               @LoggedIn User user,
               @Reliable @PayBy(CREDIT_CARD)
Session scoped PaymentProcessor processor,
               @Default ShoppingCart cart) {…}
Bean with Constructor Injection

 @RequestScoped
 public class CheckoutHandler {
   @Inject
   public CheckoutHandler(
             @LoggedIn User user,
             @Reliable @PayBy(CREDIT_CARD)
             PaymentProcessor processor,
             @Default ShoppingCart cart) {…}
Application
scoped
Bean with Constructor Injection

@RequestScoped
public class CheckoutHandler {
  @Inject
  public CheckoutHandler(
            @LoggedIn User user,
            @Reliable @PayBy(CREDIT_CARD)
            PaymentProcessor processor,
            @Default ShoppingCart cart) {…}

   Conversation scoped
Java EE 7
 Cloudy Ahead
Layers of Cloud


  Software as a Service (SaaS)



  Platform as a Service (PaaS)



Infrastructure as a Service (IaaS)
Java EE and the Cloud
• Containers are back in vogue!
• We have containers
• We have services... injectable services...
• We scale to large clusters...
• We have a security model...
JSR 342 – Java EE for the Cloud
• More easily operate on public/private cloud
  – Multi tenancy, elasticiy
• Tighter requirements for resource and state
    management
•   Better isolation between applications
•   Potential standard APIs for NRDBMS, caching, etc.
•   Common management and monitoring interfaces
•   Evolving the platform
Better Packaging for the Cloud
• Applications should be versioned
• Multiple versions should be able to coexists
• Dealing with data versioning, upgrades, etc.
• Need the ability to specify QoS properties
• Exposed and connected to services
Cloud Platform

                  Application



  Java     Persistence     Queueing
 Service     Service        Service
                                      ...

              State Management

              Virtualization Layer
Cloud Platform

                           Application
 Code   Code   Code                                QoS
Module Module Module
                     Schema Migration Security
                                               Information         …


   Java           Persistence        Queueing
  Service           Service           Service
                                                             ...

                      State Management

                      Virtualization Layer
Cloud Platform


Application   Application   Application   Application   Application


   Java          Persistence         Queueing
  Service          Service            Service
                                                          ...

                      State Management

                      Virtualization Layer
Cloud Platform

                   Managed Environment

Application   Application   Application   Application   Application


   Java          Persistence         Queueing
  Service          Service            Service
                                                          ...

                      State Management

                      Virtualization Layer
Modularity
• Build on JavaSE 8 modularity
• Applications are composed of modules
• Dependencies are explicit
• Versioning is built-in
• Additional metadata for JavaEE
JavaSE 8 Modules
                                            com.foo.app
module-info.java
module com.foo @ 1.0.0 {    com.foo.extra
  class com.foo.app.Main
  requires com.foo.lib @ 2.1-alpha;         com.foo.lib
  provides com.foo.app.lib @ 1.0.0;
  requires optional com.foo.extra;
}


                                   org.bar.lib

                                            edu.baz.util
Packaging and Install
• Compiling Java classes with modules

$ javac -modulepath mods src/com.foo.app/...

• Packaging classes into modules

$ jpkg -modulepath mods jmod 
com.foo.app com.foo.extra com.foo.lib

• Installing modules into library

$ jmod -L mlib install 
  $EXT/edu.baz.util@*.jmod 
  $EXT/org.bar.lib@*.jmod
Modular Applications
 j1demo.app
   j1demo-1.0.3
Modular Applications
 j1demo.app               twitter-client-2.3.0
   j1demo-1.0.3
              requires   j1demo-persist-1.4.0
Modular Applications
 j1demo.app        twitter-client-2.3.0
   j1demo-1.0.3
                  j1demo-persist-1.4.0



 javaee-web-7.0                jpa-2.1    jax-rs-2.0
Modular Applications
 j1demo.app           twitter-client-2.3.0
   j1demo-1.0.3
                     j1demo-persist-1.4.0



 javaee-web-7.0                   jpa-2.1    jax-rs-2.0


        implements



 gf-appserv-4.01.


            ...
Modular Applications
 j1demo.app          twitter-client-2.3.0
   j1demo-1.0.3
                    j1demo-persist-1.4.0



 javaee-web-7.0                  jpa-2.1          jax-rs-2.0


                                     implements


 gf-appserv-4.01.          eclipselink-
                              2.1.3

            ...            jersey-2.0.5
Modular Applications
 j1demo.app          twitter-client-2.3.0    jax-rs-2.1
   j1demo-1.0.3
                    j1demo-persist-1.4.0    jersey-2.1.1



 javaee-web-7.0                  jpa-2.1




 gf-appserv-4.01.          eclipselink-
                              2.1.3

            ...
Modular Applications
 j1demo.app          twitter-client-2.3.0         jax-rs-2.1
   j1demo-1.0.3
                    j1demo-persist-1.4.0        jersey-2.1.1



 javaee-web-7.0                  jpa-2.1    jax-rs-2.1




 gf-appserv-4.01.          eclipselink-
                              2.1.3

            ...            jersey-2.1.1
<Insert Picture Here>




Status
Web Tier
• Web socket support in Servlet container
• Standard JSON API
• HTML5 support in JSF
• NIO2 based web container
• Updates to Web Profile
• JAX-RS 2.0 will be mandatory
New API
• Concurrency Utilities – JSR 236
   – Eg. transaction-, security- naming- aware ExecutorService
• JCache – JSR 107
   – Local cache API, key-value map
   – Needs to be aligned with JPA cache API
• JMS 2.0
   – Annotation based programming model to JMS
• JSON 1.0
• RESTful client API for JAX-RS 2.0
Java EE 7 JSRs Status
           Approved                    Ongoing
•   JPA 2.1                    • Concurrency Utilities 1.0
•   JAX-RS 2.0                 • JCache 1.0
•   Servlet 3.1
•   EL 3.0                             Yet to be filed
•   Platform 7/Web Profile 7   •   EJB 3.2
•   JMS 2.0                    •   CDI 1.1
•   JSF 2.2                    •   JSR-330 1.1
                               •   Bean Validation 1.1
                               •   JSON 1.0
Java EE 7 Schedule
• First seven JSRs already filed
• Remaining ones to be filed soon...
   – Stay tuned
• Final release late 2012
• Date driven release
   – Anything not ready will be deferred to Java EE 8
JavaEE 6 on the Cloud Today
JRockit Virtualized Edition
                      • Oracle JRockit VE runs
                       natively on hypervisor
                         – Better performance
                         – Improved security
                      • Deterministic GC
                        behaviour
                         – “Soft” real-time
                      • Simple administration
                         – Console and scripting
Java EE 6 Platform

Available from
http://www.oracle.com/javaee
Java EE 7
Reaching for the Cloud
Lee Chuk Munn
chuk-munn.lee@oracle.com

Java EE 與 雲端運算的展望

  • 2.
    Java EE 7 Reachingfor the Cloud Lee Chuk Munn chuk-munn.lee@oracle.com
  • 3.
    The following isintended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle's products remains at the sole discretion of Oracle.
  • 4.
    Java EE 6Platform December 10, 2009
  • 5.
  • 6.
  • 7.
  • 8.
    What is Newin Java EE 6? • Several new APIs • Web profile • Pluggability/extensibility • Dependency injection • Lots of improvements to existing API
  • 9.
    New And UpdatedComponents • EJB 3.1 (+Lite) • Managed Beans 1.0 • JPA 2.0 • Interceptors 1.1 • Servlet 3.0 • JSP 2.2 • JSF 2.0 • EL 2.2 • JAX-RS 1.1 • JSR-250 1.1 • Bean Validation 1.0 • JASPIC 1.1 • DI 1.0 • JACC 1.5 • CDI 1.0 • JAX-WS 2.2 • Connectors 1.6 • JSR-109 1.3
  • 10.
    Java EE 6Web Profile Web container JSP 2.2 extensions JSF 2.0 JSTL 1.2 CDI Bean Validation 1.0 extensions Servlet 3.0 · EL 2.2 DI 1.0 · CDI 1.0 · Interceptors 1.1 · JSR-250 1.1 Managed Beans 1.0 EJB 3.1 Lite JPA 2.0 · JTA 1.1
  • 11.
    Web Tier Updates •Annotations in Servlet 3.0 • Automatic discovery and registration of libraries • web.xml is optional • Package static files in resource jars • Use EJBs directly inside web apps
  • 12.
    Web Apps SimplifiedPackaging Web Application WEB-INF/classes com/acme/MyServlet.class com/acme/MyFilter.class WEB-INF/lib someframework.jar WEB-INF/web.xml index.html main.css jquery-1.4.2.js ui/jquery.ui.core.js ui/jquery.ui.widget.js
  • 13.
    Web Apps SimplifiedPackaging Web Application WEB-INF/classes @WebServlet(urlPatterns=”/foo”) com/acme/MyServlet.class public class MyServlet { … } com/acme/MyFilter.class WEB-INF/lib @WebFilter(urlPatterns=”/foo”) someframework.jar public class MyFilter { … } WEB-INF/web.xml index.html main.css jquery-1.4.2.js ui/jquery.ui.core.js ui/jquery.ui.widget.js
  • 14.
    Web Apps SimplifiedPackaging Web Application WEB-INF/classes com/acme/MyServlet.class com/acme/MyFilter.class Framework Jar WEB-INF/lib META-INF/web-fragment.xml someframework.jar com/fw/FwServlet.class com/fw/FwFilter.class index.html main.css jquery-1.4.2.js ui/jquery.ui.core.js ui/jquery.ui.widget.js
  • 15.
    Web Apps SimplifiedPackaging Web Application WEB-INF/classes com/acme/MyServlet.class com/acme/MyFilter.class WEB-INF/lib someframework.jar jQuery Resource Jar jquery-ui-1.8.4.jar META-INF/resources/jquery-1.4.2.js META-INF/resources/ui/jquery.ui.core.js META-INF/resources/ui/jquery.ui.widget.js index.html main.css
  • 16.
    Web Apps SimplifiedPackaging Web Application • Self-contained WEB-INF/classes • Generic com/acme/MyServlet.class • Reusable com/acme/MyFilter.class WEB-INF/lib someframework.jar jquery-ui-1.8.4.jar index.html main.css
  • 17.
    Java EE 6Programming Model • Complementary declarative/programmatic layer • Annotations are additive • Code can evolve gradually • Managed beans as a common foundation
  • 18.
    EJB 3.1 Lite •Session bean programming model • Stateless, singleton programming model • Annotation based declarative security and transactions • Deployment descriptors are optional
  • 19.
    EJB 3.1 NewFirst Class Construct @Singleton @Startup public class StartupBean { @PostConstruct public void doAtStartup() { … } } @Stateless public class BackupBean { @Schedule(dayOfWeek=”Fri”, hour=”3”, minute=”15”) public void performBackup() { … } } @Stateless public class BatchProcessor { @Asynchronous public Future<Result> submit(Task t){ … } }
  • 20.
    Dependency Injection • Powerfultype-safe model • Can be enabled per-module • Integrated with JSF, JSP, EJB, web tier • Friendly to pre-Java EE 6 resources and services • Event model • Highly extensible
  • 21.
    Bean with ConstructorInjection @RequestScoped public class CheckoutHandler { @Inject public CheckoutHandler( @LoggedIn User user, @Reliable @PayBy(CREDIT_CARD) PaymentProcessor processor, @Default ShoppingCart cart) {…}
  • 22.
    Bean with ConstructorInjection @RequestScoped public class CheckoutHandler { @Inject public CheckoutHandler( @LoggedIn User user, @Reliable @PayBy(CREDIT_CARD) Types PaymentProcessor processor, @Default ShoppingCart cart) {…}
  • 23.
    Bean with ConstructorInjection @RequestScoped public class CheckoutHandler { @Inject public CheckoutHandler( @LoggedIn User user, @Reliable @PayBy(CREDIT_CARD) Qualifiers PaymentProcessor processor, @Default ShoppingCart cart) {…}
  • 24.
    Bean with ConstructorInjection Request scoped @RequestScoped public class CheckoutHandler { @Inject public CheckoutHandler( @LoggedIn User user, @Reliable @PayBy(CREDIT_CARD) PaymentProcessor processor, @Default ShoppingCart cart) {…}
  • 25.
    Bean with ConstructorInjection @RequestScoped public class CheckoutHandler { @Inject public CheckoutHandler( @LoggedIn User user, @Reliable @PayBy(CREDIT_CARD) Session scoped PaymentProcessor processor, @Default ShoppingCart cart) {…}
  • 26.
    Bean with ConstructorInjection @RequestScoped public class CheckoutHandler { @Inject public CheckoutHandler( @LoggedIn User user, @Reliable @PayBy(CREDIT_CARD) PaymentProcessor processor, @Default ShoppingCart cart) {…} Application scoped
  • 27.
    Bean with ConstructorInjection @RequestScoped public class CheckoutHandler { @Inject public CheckoutHandler( @LoggedIn User user, @Reliable @PayBy(CREDIT_CARD) PaymentProcessor processor, @Default ShoppingCart cart) {…} Conversation scoped
  • 28.
    Java EE 7 Cloudy Ahead
  • 29.
    Layers of Cloud Software as a Service (SaaS) Platform as a Service (PaaS) Infrastructure as a Service (IaaS)
  • 30.
    Java EE andthe Cloud • Containers are back in vogue! • We have containers • We have services... injectable services... • We scale to large clusters... • We have a security model...
  • 31.
    JSR 342 –Java EE for the Cloud • More easily operate on public/private cloud – Multi tenancy, elasticiy • Tighter requirements for resource and state management • Better isolation between applications • Potential standard APIs for NRDBMS, caching, etc. • Common management and monitoring interfaces • Evolving the platform
  • 32.
    Better Packaging forthe Cloud • Applications should be versioned • Multiple versions should be able to coexists • Dealing with data versioning, upgrades, etc. • Need the ability to specify QoS properties • Exposed and connected to services
  • 33.
    Cloud Platform Application Java Persistence Queueing Service Service Service ... State Management Virtualization Layer
  • 34.
    Cloud Platform Application Code Code Code QoS Module Module Module Schema Migration Security Information … Java Persistence Queueing Service Service Service ... State Management Virtualization Layer
  • 35.
    Cloud Platform Application Application Application Application Application Java Persistence Queueing Service Service Service ... State Management Virtualization Layer
  • 36.
    Cloud Platform Managed Environment Application Application Application Application Application Java Persistence Queueing Service Service Service ... State Management Virtualization Layer
  • 37.
    Modularity • Build onJavaSE 8 modularity • Applications are composed of modules • Dependencies are explicit • Versioning is built-in • Additional metadata for JavaEE
  • 38.
    JavaSE 8 Modules com.foo.app module-info.java module com.foo @ 1.0.0 { com.foo.extra class com.foo.app.Main requires com.foo.lib @ 2.1-alpha; com.foo.lib provides com.foo.app.lib @ 1.0.0; requires optional com.foo.extra; } org.bar.lib edu.baz.util
  • 39.
    Packaging and Install •Compiling Java classes with modules $ javac -modulepath mods src/com.foo.app/... • Packaging classes into modules $ jpkg -modulepath mods jmod com.foo.app com.foo.extra com.foo.lib • Installing modules into library $ jmod -L mlib install $EXT/edu.baz.util@*.jmod $EXT/org.bar.lib@*.jmod
  • 40.
  • 41.
    Modular Applications j1demo.app twitter-client-2.3.0 j1demo-1.0.3 requires j1demo-persist-1.4.0
  • 42.
    Modular Applications j1demo.app twitter-client-2.3.0 j1demo-1.0.3 j1demo-persist-1.4.0 javaee-web-7.0 jpa-2.1 jax-rs-2.0
  • 43.
    Modular Applications j1demo.app twitter-client-2.3.0 j1demo-1.0.3 j1demo-persist-1.4.0 javaee-web-7.0 jpa-2.1 jax-rs-2.0 implements gf-appserv-4.01. ...
  • 44.
    Modular Applications j1demo.app twitter-client-2.3.0 j1demo-1.0.3 j1demo-persist-1.4.0 javaee-web-7.0 jpa-2.1 jax-rs-2.0 implements gf-appserv-4.01. eclipselink- 2.1.3 ... jersey-2.0.5
  • 45.
    Modular Applications j1demo.app twitter-client-2.3.0 jax-rs-2.1 j1demo-1.0.3 j1demo-persist-1.4.0 jersey-2.1.1 javaee-web-7.0 jpa-2.1 gf-appserv-4.01. eclipselink- 2.1.3 ...
  • 46.
    Modular Applications j1demo.app twitter-client-2.3.0 jax-rs-2.1 j1demo-1.0.3 j1demo-persist-1.4.0 jersey-2.1.1 javaee-web-7.0 jpa-2.1 jax-rs-2.1 gf-appserv-4.01. eclipselink- 2.1.3 ... jersey-2.1.1
  • 47.
  • 48.
    Web Tier • Websocket support in Servlet container • Standard JSON API • HTML5 support in JSF • NIO2 based web container • Updates to Web Profile • JAX-RS 2.0 will be mandatory
  • 49.
    New API • ConcurrencyUtilities – JSR 236 – Eg. transaction-, security- naming- aware ExecutorService • JCache – JSR 107 – Local cache API, key-value map – Needs to be aligned with JPA cache API • JMS 2.0 – Annotation based programming model to JMS • JSON 1.0 • RESTful client API for JAX-RS 2.0
  • 50.
    Java EE 7JSRs Status Approved Ongoing • JPA 2.1 • Concurrency Utilities 1.0 • JAX-RS 2.0 • JCache 1.0 • Servlet 3.1 • EL 3.0 Yet to be filed • Platform 7/Web Profile 7 • EJB 3.2 • JMS 2.0 • CDI 1.1 • JSF 2.2 • JSR-330 1.1 • Bean Validation 1.1 • JSON 1.0
  • 51.
    Java EE 7Schedule • First seven JSRs already filed • Remaining ones to be filed soon... – Stay tuned • Final release late 2012 • Date driven release – Anything not ready will be deferred to Java EE 8
  • 52.
    JavaEE 6 onthe Cloud Today
  • 53.
    JRockit Virtualized Edition • Oracle JRockit VE runs natively on hypervisor – Better performance – Improved security • Deterministic GC behaviour – “Soft” real-time • Simple administration – Console and scripting
  • 54.
    Java EE 6Platform Available from http://www.oracle.com/javaee
  • 55.
    Java EE 7 Reachingfor the Cloud Lee Chuk Munn chuk-munn.lee@oracle.com