Page 1
Slide 1Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
JPEProject
J2EE 1.2Servlet, JSP,
EJB, JMSRMI/IIOP
J2EE 1.3CMP,
ConnectorArchitecture
J2EE 1.4Web Services, Management, Deployment, Async. Connector
Java EE 5Ease of DevelopmentAnnotationsEJB 3.0Persistence APINew and Updated Web Services
Robustness
Web Services
Enterprise Java Platform
`
Java EE 6EJB LiteRestful WSWeb BeansExtensibility
Java EE 6Web Profile
Ease ofDevelopment
Right Sizing
Java EE: Past & Present
Creating Quick & Powerful Web Applications with Oracle, GlassFish, NetBeans / Eclipse
Arun Gupta, GlassFish GuySun Microsystems, Inc.blog.arungupta.me
1
Page 2
Slide 2Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
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
Page 3
Slide 3Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
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
Page 4
Slide 4Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Sun GlassFish Enterprise Server
Customer FocusedCustomer Focused
Support TeamSupport Team
Patches &Patches &
UpgradesUpgrades
24x7 Support24x7 Support
CustomerCustomer
AdvocateAdvocate
Sun VIPSun VIP
InteroperabilityInteroperability
SupportSupport
Enterprise ManagerEnterprise Manager
eLearningeLearning
CreditCredit
GlassFishGlassFish
Open SourceOpen Source
Application ServerApplication Server
Page 5
Slide 5Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Java EE 6: Ease of Development (EJB.Lite)
foo.ear
foo_web.warWEB-INF/web.xmlWEB-INF/classes com.sun.FooServlet com.sun.TickTock
foo_ejb.jarcom.sun.FooBeancom.sun.FooHelper
foo.war
WEB-INF/classes com.sun.FooServlet com.sun.TickTock com.sun.FooBean com.sun.FooHelper
web.xml ?
Java EE 5 Java EE 6
Page 6
Slide 6Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
EoD Example - Servlets<!--Deployment descriptor
web.xml -->
<web-app><servlet> <servlet-name>MyServlet
</servlet-name> <servlet-class> com.foo.MyServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>MyServlet </servlet-name> <url-pattern>/myApp/* </url-pattern> </servlet-mapping> ... </web-app>
Servlet in Java EE 5: Create two source files/* Code in Java Class */
package com.foo;public class MyServlet extends HttpServlet {public void doGet(HttpServletRequest req,HttpServletResponse res)
{
...
}
...
}
Page 7
Slide 7Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
EoD Example - ServletsServlet 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)
{...
}
Page 8
Slide 8Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
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/
Java EE 6 Wizards
Page 9
Slide 9Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
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, ...
Page 10
Slide 10Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
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;
}
...
}
Page 11
Slide 11Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
http://blog.arungupta.me/2009/09/totd-107-connect-to-oracle-database-using-netbeans/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-99-creating-a-java-ee-6-application-using-mysql-jpa-2-0-and-servlet-3-0-with-glassfish-tools-bundle-for-eclipse/
JPA Wizards
Page 12
Slide 12Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
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
Page 13
Slide 13Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
JAX-RS Sample@Path("widgets/{id}")@Produces("application/widgets+xml")@Consumes("application/widgets+xml")public class WidgetResource {
private Widget w;
public WidgetResource(@PathParam("id") String id) { this.w = locateRecord(id); }
@GET Widget getWidget() { return w; }
@PUT Widget updateWidget(Widget update) { w = processUpdate(update); return w; }
}
Page 14
Slide 14Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
http://blog.arungupta.me/2009/10/totd-112-exposing-oracle-database-tables-as-restful-entities-using-jax-rs-glassfish-and-netbeans/
RESTful Wizards
Page 15
Slide 15Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Dynamic Languages & Frameworks
http://glassfish-scripting.dev.java.net
Page 16
Slide 16Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
Rails Deployment Choices
Credits: http://birdwatchersdigest.com
Page 17
Slide 17Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
http://blog.arungupta.me/2008/11/screencast-26-developrundebug-rails-application-using-netbeans-ide-and-glassfish-v3-prelude/http://blog.arungupta.me/2009/10/totd-110-jruby-on-rails-application-using-oracle-on-glassfish/http://blog.arungupta.me/2009/10/totd-111-rails-scaffold-for-a-pre-existing-table-using-oracle-and-glassfish/
Page 18
Slide 18Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
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
Page 19
Slide 19Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
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/
Page 20
Slide 20Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
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/
Page 21
Slide 21Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
References
• glassfish.org• blogs.sun.com/theaquarium• twitter.com/glassfish• [email protected]
Page 22
Slide 22Creating Quick and Powerful Web Applications using Oracle, GlassFish and NetBeans/Eclipse
JPEProject
J2EE 1.2Servlet, JSP,
EJB, JMSRMI/IIOP
J2EE 1.3CMP,
ConnectorArchitecture
J2EE 1.4Web Services, Management, Deployment, Async. Connector
Java EE 5Ease of DevelopmentAnnotationsEJB 3.0Persistence APINew and Updated Web Services
Robustness
Web Services
Enterprise Java Platform
`
Java EE 6EJB LiteRestful WSWeb BeansExtensibility
Java EE 6Web Profile
Ease ofDevelopment
Right Sizing
Java EE: Past & Present
Creating Quick & Powerful Web Applications with Oracle, GlassFish, NetBeans / Eclipse
Arun Gupta, GlassFish GuySun Microsystems, Inc.blog.arungupta.me
22