Creating Quick and Powerful Web applications with Oracle, GlassFish and NetBeans/Eclipse
1. Java EE: Past & Present
Right Sizing
Ease of
Creating Quick & Powerful Development Java EE 6
EJB Lite
Web Applications withWeb Services
Java EE 5
Ease of
Restful WS
Oracle, GlassFish, Development
Web Beans
Extensibility
J2EE 1.4
NetBeans / Eclipse Web Services,
Robustness
Annotations
EJB 3.0
Enterprise Management, Persistence API
Java Platform J2EE 1.3 Deployment, New and
CMP,
Async. Updated
Connector
` Connector Java EE 6
Arun Gupta, GlassFish Guy
J2EE 1.2 Architecture Web Services
Sun Microsystems, Inc.
Servlet, JSP, Web Profile
blog.arungupta.me
JPE
Project
EJB, JMS
RMI/IIOP
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse 1
Slide 1
2. What is GlassFish ?
• A Community
> Users, Partners, Testers, Developers, ...
> Started in 2005 on java.net
• Application Server
> Enterprise Quality and Open Source (CDDL & GPL v2)
> Java EE 5 / 6 Reference Implementation
> Full Commercial Support from Sun
http://glassfish.org
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Slide 2
3. State of GlassFish
• GlassFish v2
> Java EE 5 Reference Implementation
> Clustering, Load-balancing, High Availability
> Web-based / CLI Administration Console
> .NET Web services interoperability
> Current release: GlassFish v2.x
• GlassFish v3
> Java EE 6 Reference Implementation
> Modular (OSGi), Embeddable, Extensible
> Java EE, Rails, Grails, Django, ...
> Going final this year
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Slide 3
4. Sun GlassFish Enterprise Server
Enterprise Manager
Customer
Advocate eLearning
Credit
Customer Focused 24x7 Support
Support Team
GlassFish
Open Source
Sun VIP
Application Server Patches &
Interoperability
Upgrades
Support
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Slide 4
5. Java EE 6: Ease of Development (EJB.Lite)
Java EE 5 Java EE 6
foo.ear foo.war
foo_web.war WEB-INF/classes
com.sun.FooServlet
com.sun.TickTock
WEB-INF/web.xml com.sun.FooBean
WEB-INF/classes com.sun.FooHelper
com.sun.FooServlet
com.sun.TickTock
foo_ejb.jar
com.sun.FooBean
com.sun.FooHelper
web.xml ?
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Slide 5
6. EoD Example - Servlets
Servlet in Java EE 5: Create two source files
<!--Deployment descriptor /* Code in Java Class */
web.xml -->
<web-app> package com.foo;
<servlet> public class MyServlet
<servlet-name>MyServlet extends HttpServlet {
</servlet-name> public void
<servlet-class> doGet(HttpServletRequest
com.foo.MyServlet
</servlet-class> req,HttpServletResponse res)
</servlet> {
<servlet-mapping>
<servlet-name>MyServlet ...
</servlet-name>
<url-pattern>/myApp/* }
</url-pattern>
</servlet-mapping>
... ...
</web-app>
}
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Slide 6
7. EoD Example - Servlets
Servlet in Java EE 6: In many cases a single source file
package com.foo;
@WebServlet(name=”MyServlet”, urlPattern=”/myApp/*”)
public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest req,
HttpServletResponse res)
{
...
}
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Slide 7
8. Java EE 6 Wizards
http://blog.arungupta.me/2008/11/screencast-27-simple-web-application-using-netbeans-6-5-ide-and-glassfish-v3-prelude/
http://blog.arungupta.me/2009/10/totd-108-java-ee-6-web-application-jsf-2-0-jpa-2-0-ejb-3-1-using-oracle-netbeans-and-glassfish/
http://blog.arungupta.me/2009/08/totd-94-a-simple-java-server-faces-2-0-jpa-2-0-application-getting-started-with-java-ee-6-using-netbeans-6-8-m1-glassfish-v3/
http://blog.arungupta.me/2009/08/totd-95-ejb-3-1-java-server-faces-2-0-jpa-2-0-web-application-getting-started-with-java-ee-6-using-netbeans-6-8-m1-glassfish-v3/
http://blog.arungupta.me/2008/11/screencast-28-simple-web-application-using-eclipse-and-glassfish-v3-prelude/
http://blog.arungupta.me/2009/09/totd-102-java-ee-6-servlet-3-0-and-ejb-3-1-wizards-in-eclipse/
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Slide 8
9. Java Persistence API
• Java EE specification that defines Object to
Relational Mapping
• Annotations to persist POJOs
• JPQL to query database objects
• Requires a Persistence Provider and a Database
> Common Persistence Providers: TopLinkEssentials,
EclipseLink, ...
> Common Databases: Oracle, MySQL, ...
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Slide 9
10. JPA Sample
@Entity class Employee {
@Id private int id;
private String firstName;
private String lastName;
pubic Employee (int id,
String firstName,
String lastName) {
...
}
public String getFullName(){
return firstName + lastName;
}
...
}
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Slide 10
12. RESTful Web Services
• JAX-RS: Java API for RESTful Web Services
• Annotation-based server-side API
• HTTP-centric
• Jersey: Implementation of JAX-RS
> Also provides client-side API
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Slide 12
15. Dynamic Languages & Frameworks
http://glassfish-scripting.dev.java.net
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Slide 15
16. Rails Deployment Choices
Credits: http://birdwatchersdigest.com
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Slide 16
18. Extending GlassFish ... 1, 2, 3.
@Service(name="mycommand")
@Scoped(PerLookup.class)
public class CLIPluggabilityCommand implements AdminCommand {
...
}
...
// this value can be either runtime or os for our demo
@Param(primary=true)
String inParam;
...
public void execute(AdminCommandContext context) {
...
}
http://java.net/blog/2008/11/07/extending-glassfish-v3-prelude-easy-1-2-3
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Slide 18
19. Light-weight & On-demand Monitoring
• Event-driven light-weight and non-intrusive
monitoring
• Modules provide domain specific probes
(monitoring events)
> EJB, Web, Connector, JPA, Jersey, Orb, Ruby
• End-to-end monitoring on Solaris using DTrace
• 3rd party scripting clients
> JavaScript to begin with
http://blog.arungupta.me/2009/09/totd-104-glassfish-v3-monitoring-how-to-monitor-a-rails-app-using-asadmin-javascript-jconsole-rest/
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Slide 19
20. REST Interface
• REST interface to management and
monitoring data
> Configuration data, Commands invocation (start/stop
instance, deploy, undeploy, ...), CRUD resources (JMS,
JDBC, ...)
> localhost:4848/management/domain
> localhost:4848/monitoring/domain
• GET, POST, DELETE methods
• XML, JSON, HTML reps
http://blog.arungupta.me/2009/08/totd-96-glassfish-v3-rest-interface-to-monitoring-and-management-json-xml-and-html-representations/
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Slide 20
21. References
• glassfish.org
• blogs.sun.com/theaquarium
• twitter.com/glassfish
• glassfish@sun.com
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Slide 21
22. Java EE: Past & Present
Right Sizing
Ease of
Creating Quick & Powerful Development Java EE 6
EJB Lite
Web Applications withWeb Services
Java EE 5
Ease of
Restful WS
Oracle, GlassFish, Development
Web Beans
Extensibility
J2EE 1.4
NetBeans / Eclipse Web Services,
Robustness
Annotations
EJB 3.0
Enterprise Management, Persistence API
Java Platform J2EE 1.3 Deployment, New and
CMP,
Async. Updated
Connector
` Connector Java EE 6
Arun Gupta, GlassFish Guy
J2EE 1.2 Architecture Web Services
Sun Microsystems, Inc.
Servlet, JSP, Web Profile
JPE EJB, JMS
blog.arungupta.me
Project RMI/IIOP
Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse 22
Slide 22