1
GlassFish
Developing an Application Server in Open Source
Santiago Pericas-Geertsen
Sun Microsystems, Inc.
http://weblogs.java.net/blog/spericas/
Who am I ?
• BA from ITBA
• MA and PhD from Boston University
• With Sun for over 6 years
• Part of Glassfish team
> Worked on numerous projects: XSLTC (XSLT Compiler in JDK),
JAXP, Fast Web Services, Fast Infoset, JAX-WS, XML Performance, Japex, MEP, ...
3
Part I - Glassfish
Application Server and Community
What is GlassFish?
• A Community
> Users, Partners, Testers, Developers, ... > Started in 2005 on java.net
• Application Server (version 2)
> Enterprise Quality and Open Source (CDDL & GPL v2) > Java EE 5 Reference Implementation
> Full Commercial Support from Sun
• Growing organically into other Middleware Areas
• Leverages Sun's experience in other Java, Middleware, SDK
GlassFish – The Best Open Source Application Server 5
Glassfish Ecosystem
Project GlassFish Derby Open ESB Portal Server MQ Java EE RI & SDK Sun GlassFish Enterprise Server 2.x Java EE RI & SDKUsers and Other Groups
Open Data Sync
Frameworks and Applications
JSPwiki MyFaces ADF Integration ORB BIRT AJAX Shale Apache Httpd Facelets OSCache SiteMesh StringBeans Portal Tapestry jBPM WebDAV Project Tango OSWorkFlow CJUG-Classifieds MC4J DOJO Quercus PHP SEAMGlassFish – The Best Open Source Application Server 7
GlassFish v2 Features
• Java EE 5 compliant
• Metro: .NET 3.0 web services interoperability
• Clustering Architecture
• Support for scripting languages
• Modular and ultra fast web tier
• Seamless IDE and tools integration
> NetBeans, Eclipse, IntelliJ, Ant, Maven
• Support for the latest technologies (e.g., JAX-RS)
Java EE 5 = (J2EE 1.4).next
• Java EE 5 Theme: Ease of Development
• POJO-based programming
> More freedom, fewer requirements
• Extensive use of annotations
> Reduced need for deployment descriptors > Annotations are the default
• Resource Injection
GlassFish – The Best Open Source Application Server 9
.NET Interoperability using Metro
• High level web services stack
• Fully interoperable with .NET 3.0
• Security, Reliability and Transactions
Metro Overview (.NET Interop)
Security
Metro – GlassFish Web Services Stack metro.dev.java.net
JAXB JAXP SAAJ
Transactions Reliability
SOAP
XML Processing Web Services Core
HTTP
. . .
. . .
GlassFish – The Best Open Source Application Server 11
Clustering Architecture
• Enhances scalability and availability
> Transparent failures
> Ability to add more nodes to cluster
• Runtime view of cluster
> Router/Failover/Load Balancing module > Management module
C lu st er ed In st an ce s
Clustering Architecture
Node A AS AS Node B AS AS Node C AS AS AS . . .Message Routing / Failover / Load Balancing
M an ag em en t
HA Application State Repository
GlassFish – The Best Open Source Application Server 13
Ajax and Scripting Activities
• Dynamic Languages
> glassfish-scripting.dev.java.net
• jMaki - http://ajax.dev.java.net
> Very easily encapsulates Ajax widgets
• DynaFaces - http://jsf-extensions.dev.java.net
Web Tier
• JSP Container
> 10x perf. improvement in JSP compilation (JSR-199)
• Grizzly
> Easy-to-use, highly scalable and customizable HTTP
Framework
> Based on java.nio
GlassFish – The Best Open Source Application Server 15
World Record Performance
SpecjAppServer 2004
> July 2007: #1 score on T2000
>883.66 JOPS@Standard for GlassFish v2
>Improved in areas not covered by benchmark
>10% faster than BEA WebLogic
>30% faster than IBM WebSphere 6.1
Sun BEA IBM JBoss 0 100 200 300 400 500 600 700 800 900 SPECjAppServer 2004 Results
?
Disclaimers: SPEC and the benchmark name SPECjAppServer 2004 are registered trademarks of the Standard Performance Evaluation Corporation. Competitive benchmark results stated above reflect results published on www.spec.org as of 11/21/07. The comparison presented is based on GlassFish v2 UR1 run on 6 Sun SPARC Enterprise T5120 (1 chip, 8 cores/chip, 8 threads/core) 1.4GHz 8,439.36 SPECjAppServer2004 JOPS@Standard. For the latest SPECjAppServer 2004 benchmark results, visit http://www.spec.org/.
GlassFish Adoption
• Millions of downloads• Dozens of external committers
• Over 8,000 members
• Excellent analyst reviews
GlassFish – The Best Open Source Application Server 17
Some Adoption Indicators
• 2.5m+ hits in 13 months
• 310k+ different IPs
• 150k registrations in 7 months
GlassFish – The Best Open Source Application Server 19
GlassFish Deployment
GlassFish – The Best Open Source Application Server 21
So Why GlassFish?
• Java EE 5 (vs. Tomcat, JBoss, Websphere)
• Performance! (vs. JBoss)
• Administration (vs. JBoss, Tomcat)
• Enterprise-ready (vs. JBoss, Tomcat)
• Enterprise support (vs. Tomcat)
• Ecosystem: OpenSSO, OpenESB, etc...
• Community (vs. Weblogic, Websphere)
GlassFish – The Best Open Source Application Server 23
Reference
• http://glassfish.org • http://blogs.sun.com/theaquarium • http://blogs.sun.com/stories • http://blogs.sun.com/glassfishforbusiness • http://wiki.glassfish.java.netFast, Easy & Reliable Modular, Embedable, Extensible
Part II – Technology
Highlight
GlassFish – The Best Open Source Application Server 25
Introduction to REST
•
Give everything an ID
•
Link things together
•
Use standard methods (HTTP)
•
Allow for multiple representations
Give Everything an ID
• ID is a URI
> http://mycompany.com/customers/corporationX > http://mycompany.com/products/125
GlassFish – The Best Open Source Application Server 27
Link Things Together
• Customer order #5455
<order self="http://mycompany.com/orders/5455">
<customer ref="http://mycompany.com/customers/corporationX"/> <product ref="http://mycompany.com/products/125"/>
<amount value="3"/> </order>
• New identifiers are created
http://mycompany.com/orders/5455/customer
Use Standard Methods
Method Purpose
GET
Read, possibly cached
POST
Create without a known ID
PUT
Update or create with a known ID
GlassFish – The Best Open Source Application Server 29
Multiple Representations
• Offer data in a variety of formats
> XML > JSON > (X)HTML
• Maximize reach
• Support content negotiation
> Accept header
GET /foo
Accept: application/json
> URI-based
Stateless Communications
• Long lived identifiers
• Avoid sessions
GlassFish – The Best Open Source Application Server 31
REST using JAX-RS
• Operations such as,
GET http://mycompany.com/orders/5455
PUT http://mycompany.com/customers/corporationX
are mapped to resource class methods
• Mapping is controlled using Java annotations
• Resource classes are deployed as web applications in Glassfish
Example Using JAX-RS
@Path("orders/{order_id}")
public class OrderResource { @GET
@ProduceMime(“application/xml”) String getOrder(
@PathParam("order_id") String id) {
return “<order> ... </order>”; }
GlassFish – The Best Open Source Application Server 33
Example Using JAX-RS (contd.)
@GET
@ProduceMime(“application/html”) String getOrderHtml(
@PathParam("order_id") String id) {
return “<html><h1>Order id:” + id + “</h1>...</html>”;
Example Using JAX-RS (contd.)
@Path(“customer”)
CustomerResource getCustomer(
@PathParam("order_id") String id) {
return new CustomerResource(
getOrder(id).getCustomer()); }
... }
GlassFish – The Best Open Source Application Server 35
Conclusions
• Glassfish community is growing rapidly
> And you should be part of it!
• World class performance and J2EE 5.0 compliance
• Glassfish v3 already under way
• All the latest technologies including RESTful web services are available in Glassfish and Netbeans
Thank You
Santiago Pericas-Geertsen
Sun Microsystems, Inc.