Java EE and Glassfish


Published on

Published in: Technology
  • Be the first to comment

Java EE and Glassfish

  1. 1. GlassFish and the Future of Java EE Carol McDonald Java Architect Sun Microsystems, Inc. 1
  2. 2. Agenda Java EE 5 Overview GlassFish v2 – Today Java EE 6 and Future GlassFish v3 – The Future Summary and Resources
  3. 3. History of Enterprise Java Ease of Development 6 Java EE 5 Web Ease of Services 5 Development J2EE 1.4 Annotations ` Web Services, EJB 3.0 4 Robustness Management, Persistence API Enterprise Java J2EE 1.3 Deployment, New and Platform Updated 3 CMP, Async. Connector Web Services Connector J2EE 1.2 Architecture JavaServer Faces 2 Servlet, JSP, EJB, JMS 1 JPE RMI/IIOP Project 0 May 1998 Dec 1999 Sept 2001 Nov 2003 March 2005
  4. 4. Java EE 5 Overview
  5. 5. Java EE 5.0 Summary How is it easier? J2EE 1.4 Java EE Deployment Java language descriptors annotations @ Required container Plain Old Java interfaces Objects (POJOs) JNDI Lookups Dependency Injection Deployment descriptor, interfaces More and better defaults No Supported UI Framework Java Server Faces (JSF)
  6. 6. Catalog Sample Java EE Application Registration Application Managed Bean Entity Class Item DB ManagedBean Catalog Session Bean JSF Components
  7. 7. Entity Classes Use JPA to map/retrieve data from the database as Java Object Item ID NAME DESC URL @Entity public class Item { @Id int id; String name; String descr; String url; }
  8. 8. Catalog Statelesst eSession EJB, JPA Query e p e n d e n c y S t a l e s s S e s s io n D In j e c t io n B e a n A n n o t a t io n @Stateless public class Catalog implements CatalogService { @PersistenceContext(unitName=”PetCatalogPu”) EntityManager em; @TransactionAttribute(NOT_SUPPORTED) public List<Item> getItems(int firstItem, int batchSize) { Query q = em.createQuery ("select i from Item as i"); q.setMaxResults(batchSize); q.setFirstResult(firstItem); List<Item> items= q.getResultList(); return items; } }
  9. 9. Catalog Sample Java EE Application Registration Application Managed Bean Entity Class Item DB ManagedBean Catalog Session Bean JSF Components
  10. 10. Managed Bean: ItemController public class ItemController { D e p e n d e n c y In j e c t io n private DataModel model; private int batchSize = 10; private int firstItem = 0; @EJB private CatalogService catalog; public DataModel getItems() { model = new ListDataModel( catalog.getItems( firstItem,batchSize); return model; } ...
  11. 11. list.jsp Page <h:dataTable value='#{itemController.items}' var='dataTable <h:column>      … <h:commandLink action='#{item.detailSetup}' value='#{}'/>       <h:column> ... <h:graphicImage url='#{dataTableItem.imagethumburl}'/ …       <h:column> <h:outputText value='#{dataTableItem.price}'/> ... </h:dataTable>
  12. 12. Glassfish and MySQL Part 2
  13. 13. Demo Netbeans 6.5 JPA entity JSF pages generation from DB tables
  14. 14. Java EE 5 Web Services
  15. 15. Catalog Sample JAX-WS Application Registration Application Managed Bean Entity Class Item DB SOAP ManagedBean Catalog EJB Web Service Web Service JSF Components Client
  16. 16. Catalog EJB Web Service @WebService @Stateless public class Catalog implements CatalogService public List<Item> getItems{ ... } } public methods become web service operations WSDL/Schema generated at deploy time automatically
  17. 17. D e p e n d e n c y In j e c t io n Web Service Client public class ItemController { @WebServiceRef(wsdlLocation="http://host/Catalog/Service?wsdl") private CatalogService service; public DataModel getItems() { // Call Web Service Operation service.Catalog port = service.getCatalogPort(); List<Item> result = port.getItems(first, size); return new ListDataModel(result); } }
  18. 18. Glassfish and MySQL Part 3
  19. 19. Demo Netbeans 6.5 Glassfish v2 JAX-WS
  20. 20. RESTful Web Services with JAX-RS (JavaEE 6 but in Glassfish v2)
  21. 21. RESTful Catalog RIA App REST DataBase Registration Application Persistence-tier Web Services JAX-RS class Entity Class Item DB HTTP ItemsConverter ItemsResource JAXB class JavaFX
  22. 22. RESTful Catalog Web Service HTTP GET http://petstore/catalog/resources/items/ Ad d re s s a b l e Client Re s o u rc e s Response XML items Server We b <item> C o n t a in e r <imageurl>http://host/catalog/images/anthony.jpg</imageurl> <name>Friendly Cat</name> <price>307.10</price> <productid>feline01</productid> </item>
  23. 23. JAX-RS: Clear mapping to REST concepts High level, Declarative Uses @ annotation in POJOs Resources: what are the URIs? @Path("/items/{id}") Methods: what are the HTTP methods? @GET public XXX find() Representations: what are the formats? @Consumes("application/xml") @Produces("application/json")
  24. 24. RESTful Catalog Items Resource retrieves updates a collection of Item entities /items – URI for a list of Items Registration Application Item resource retrieves or updates one Item entity /item/1 – URI for item 1 JAX-RS class Entity Class Item DB HTTP ItemsConverter ItemsResource JAXB class JavaFX
  25. 25. Get Items resource responds to the URI http://host/catalog/items/ @Path("/items/") method public class ItemsResource { responds to HTTP GET Representation @GET @Produces("application/json") responds with JSON public ItemsConverter get(){ return new ItemsConverter( getEntities()); } Performs JPA Query, returns list of entities
  26. 26. Glassfish and MySQL Part 4
  27. 27. Demo Netbeans 6.5 Glassfish v2 JAX-RS
  28. 28. GlassFish V2
  29. 29. What is GlassFish ? Its a A Community Users, Partners, Testers, Developers, ... Started in 2005 on Application Server Enterprise Quality and Open Source (CDDL & GPL v2) Java EE 5 v2 Java EE 6 v3 Full Commercial Support from Sun
  30. 30. Timeline of Project GlassFish Tomcat Jasper Catalina v3 JSTL Struts v1 v2 Prelude v3 GlassFish Crimson UR1 UR2 Launch v2.1 XSLTC Xalan Xerces JAXB June May Sept. Nov Dec Mid-2009 JAX-RPC 2005 2006 2007 2008 2008 JSF
  31. 31. GlassFish Adoption 8M million downloads in the last year 150k registrations in 7 months Dozens of external committers Active Usage Over 7,000 members 2000000 Strong and growing partner 1800000 1600000 ecosystem 1400000 1200000 1000000 800000 600000 400000 200000 0 Fe Ma Ap Ma Ju Jul Au Se Oc No De Ja b r r y n 07 g p t v c n 07 07 07 07 07 07 07 07 07 07 08
  32. 32. GlassFish V2 Features
  33. 33. GlassFish v2: Web-based Administration
  34. 34. GlassFish v2 for Enterprises Management & Monitoring Graphical, command-line, tools, ANT ... JMX and Centralized Call Flow Self-management Diagnostic reports
  35. 35. GlassFish v2 for Enterprises Management & Monitoring Graphical, command-line, tools, ANT ... JMX and Centralized Call Flow Self-management Diagnostic reports
  36. 36. Ease-of-use – Update Center
  37. 37. SPECjAppServer 2004 Results Best-In-Class Performance 1000 900 SPECjAppServer 800 700 ? 600 500 July 2007 Record setting performance 400 300 200 10% faster than BEA WebLogic 9.2 on identical 100 server 0 Sun BEA IBM JBos Fastest complete open source result GlassFish v2, OpenSolaris, Java 6, PostgreSQ Best Price Performance Ever 2% cost of Dell, 5% cost of HP (Oracle) 13 times better price/performance
  38. 38. Web Services SOAP, Security, Reliability .NET interoperability Commons SMTP Security Reliability Transactions ... Spring JSON SOAP WSDL HTTP Web Services Core JAXB JAXP SAAJ ... XML Processing Metro – GlassFish Web Services Stack
  39. 39. Dynamic Languages & Frameworks Ajax Framework jMaki
  40. 40. GlassFish v2: IDE Support
  41. 41. Clustering And Load Balancing HTTP(S) JMS RMI/IIOP Runtime Cluster Message Routing / Failover / Load Balancing member discovery & health Management monitoring AS AS AS AS AS AS Instances Clustered through . . . AS Shoal Node A Node B Node C HA Application State Repository
  42. 42. Memory Replication for High Availability Example: Maximize Availability on 4 instance Typical cluster topology cluster on 2 nodes(machines) Instance 1 Instance 2 Instance 3 Instance 4 Machine 1 Machine 2
  43. 43. Comet: the server pushes data to the client over a long-lived HTTP connection GlassFish supports Comet Serve r Client Client 1 2
  44. 44. Ajax Push and HTTP keep-alive Comet: server pushes data to the client over a previously opened connection HTTP/1.1 Keep-Alive or Persistent Connection: keeps connection open until message or timeout Long Poll: Send a request to the server, request waits for an event, then response sent
  45. 45. GlassFish Grizzly Comet NIO: non-blocking sockets ARP Asynchronous Request Processing: Doesn't block a thread per http request availability of threads gives scalability
  46. 46. Demo Comet Slide Show Allows creation of event-driven web application which are hosted in browser
  47. 47. RESTful Web Services and Comet
  48. 48. GlassFish Eco-System
  49. 49. OpenESB JBI support OpenESB 2.0 Install, admin, and monitoring integrated in GlassFish v2 Basis for Java CAPS Release 6 Tools support NetBeans SOA 6.0 Service Engines Binding Components Many components available from
  50. 50. Extended GlassFish: OpenSSO Open SSO: Single Sign On Web Access Identity Federation Management
  51. 51. Extended GlassFish OpenPortal Standards: Portlets (2.0), Web Services for Remote Portlets, Identity: OpenSSO OpenDS 100% Java LDAPv3 Directory Service
  52. 52. The SailFin Project Bridging the HTTP and SIP protocols Ericsson SIP Servlet Contribution is available at: Visit, Download, Try, Join Milestone 1 available Built on GlassFish v2
  53. 53. (Some) Distributions & Contributors Java EE SDK GlassFish Enterprise Derby MQ Project GlassFish Portal Server Open ESB Users and Other Groups
  54. 54. Frameworks and Applications Quercus PHP OSWorkFlow OSCache Integration ORB Project Tango Apache Httpd CJUG-Classifieds BIRT jBPM DOJO Facelets MyFaces ADF Shale SiteMesh WebDAV JSPwiki SEAM Tapestry MC4J StringBeans Portal AJAX BlogTrader Wicket Equinox Java WSDP Dalma WebSphere MQ EHCache
  55. 55. GlassFish Deployment
  56. 56. GlassFish Partners Targeted at ISVs, Hosting partners & Other solution providers Profile in Partner Showcase Banner Advertising on GlassFish community and blogs Training Discounts Requirements Customer-ready support for GlassFish Associate-level member in SPA
  57. 57. Java EE 6 and Future
  58. 58. Java EE Timeline Profiles Java EE 6 EJB Lite Ease of Restful WS Development Web Beans Java EE 5 Extensibility Web Ease of Services Development J2EE 1.4 Annotations ` Web Services, Robustness EJB 3.0 Management, Persistence API Enterprise Java J2EE 1.3 Deployment, New and Platform CMP, Async. Updated Connector J2EE 1.2 Connector Web Services Java EE 6 Servlet, JSP, Architecture Web Profile JPE EJB, JMS Project RMI/IIOP
  59. 59. Major new Features in Java EE 6 Profiles targeted bundles of technologies 1st profile is the Web profile Pruning older technologies optional CMP, JAX-RPC... Extensibility Zero-configuration, drag-and-drop for web frameworks Ease of development
  60. 60. Full JSRs Java EE 6 EJB 3.1 JPA 2.0 New Features Servlet 3.0 Profiles JSF 2.0 Pruning JAX-RS 1.0 Extensibility Connector 1.6 More ease of development Bean Validation 1.0 Web Beans Maintenance JSRs JAXB 2.2 JAX-WS 2.2 JSR-109 1.3 EL 1.2 JSP 1.2 Authentication SPI 1.1 Common Annotations 1.1
  61. 61. Ease Of Development Ongoing concern focus is the web tier General principles: Annotation-based programming model web.xml not required Self-registration of third-party libraries Simplified packaging
  62. 62. Web Profile Servlet 3.0, JSP 2.1, JSR-45 (Debugging), EL 1.2, JSTL 1.2, JSF 2.0 EJB Lite 3.1, JTA 1.1, JPA 2.0, JSR-250 (Annotations)
  63. 63. EJB “Lite” Small subset of EJB 3.1 API for use in Web Profile Lite Local Session Beans Also requires JPA 2.0 / JTA 1.1 API
  64. 64. Simplified Packaging EJB components can be packaged directly inside a web application archive (war file)
  65. 65. Some Servlet 3.0 Highlights Annotation-based programming model @WebServlet @ServletFilter etc. Async APIs Useful for Comet, chat rooms, long waits
  66. 66. Some JavaServer Faces 2.0 Features custom components easier to develop Ajax support Html templates (Facelets) Reduce configuration Bookmarkable URLs
  67. 67. Some EJB 3.1 Highlights Singleton beans: @Singleton No interface view: one source file per bean Calendar timers: @Schedule(dayOfWeek=“Mon,Wed”) Async business methods: @Asynchronous Simplified testing (embeddable test outside container)
  68. 68. Session Bean with Local Business Interface...OLD... HelloBean Client <<interface> com.acme.Hello @EJB String sayHello() private Hello h; ... h.sayHello(); com.acme.HelloBean public String sayHello() { ... }
  69. 69. Session Bean with no Interface @Stateless public class HelloBean { public String sayHello(String msg) { return “Hello “ + msg; } }
  70. 70. no Interface client...NEW... @EJB HelloBean h; ... h.sayHello(“bob”);
  71. 71. Timeline June 2007 Expert group formed Q3 2008 Public draft Q4 2008 Proposed final draft Q2 2009 Final release
  72. 72. GlassFish V3 – The Future
  73. 73. GlassFish v3 Java EE 5 = GlassFish v2 GlassFish v2.1: better, faster, more scalable GlassFish v3 Prelude Web Tier Only, OSGi Based, some EE 6 previews EclipseLink (JPA) Bundled Multiple Containers (jRuby, Groovy, Phobos) GlassFish v3 = Java EE 6 Work in Progress OSGi Based All have Netbeans and Eclipse Integration
  74. 74. What's new in V3 Modularity OSGi runtime (Apache Felix) Lightweight, Fast StartUp, Scalable Service based architecture services are defined by contracts and can be easily substituted lazy loading based on usage patterns Extensible not limited to traditional Java EE containers Embeddable Runs in-VM
  75. 75. GlassFish v3 JavaEE 6 and Frameworks All JVM-Scripting Languages small to HA to Communication to Grid Preview available today
  76. 76. GlassFish v3 Architecture Portlet Groovy JRuby OpenMQ OpenESB OpenSSO Container JMS Web Connection Java Container JSF Pooling (JCA) Metro EJB Container Persistence Management Console Update Center Management CLI Naming Grizzly Framework Monitoring/ Injection Configuration Serviceability/ Service Manager Logging GlassFish V3 Core Security (Module Subsystem) Transaction Deployment Clustering Management Service OSGi NetBeans Java SE JavaWebStart
  77. 77. GlassFish v3 Runtime GlassFish v3 is an OSGi application GFv3 is de-composed into a set of modules Modules are run inside OSGi container (Apache Felix) user-defined Webtier EJB Scripting JCAPS … modules user-defined … modules GlassFish Kernel (HK2, API, etc.) Felix runtime
  78. 78. Compile/Deploy on Change Java EE development doesn't have to be painful Incremental compile of all Java EE artifacts Auto-deploy of all Java EE and static artifacts Session retention: maintain stateful sessions across re- deployments
  79. 79. v3 Prelude Usage xWiki GlassFishV3 Project Fuji JavaDB SailFin ( (Telco AppServer) WebSynergy (Portal, Liferay) EHCache Server WebEngine GlassFish v3 Embedded GlassFish v3 Embedded Jersey Jersey
  80. 80. Yes, Eclipse too ! GlassFish (v2/v3) + Eclipse 3.4 Tools Bundle:
  81. 81. GlassFish v3 Roadmap V3 Prelude Today! V3 Final aligned with Java EE 6 Starting a series of Milestone releases Targeted for Fall 2009 Clustering, central admin likely on the update center V3.1 full clustering Likely 6 to 9 months after V3
  82. 82. Summary and Resources
  83. 83. Reference Carol's Blog Fast, Easy & Reliable Modular, Embedable, Extensible
  84. 84. @ su n. co m Carol McDonald Java Architect 84