Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Building Server-Side Eclipse based web
    applications


                                                              Tutorial




        Building Server-Side Eclipse based web applications | Tutorial
        © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
1       Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
The authors

    Jochen Hiller                                                                  Simon Kaegi
    Deutsche Telekom AG, Germany                                                   IBM Rational Software, Canada
    jo.hiller@googlemail.com                                                       simon_kaegi@ca.ibm.com
                                                                                   Equinox, e4 Committer


                                                                                   Gunnar Wagenknecht
                                                                                   AGETO, Germany
                                                                                   gunnar@wagenknecht.org
                                                                                   Eclipse Committer




           Building Server-Side Eclipse based web applications | Tutorial
           © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
2          Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Overview
    • Introduction to Server-Side Eclipse
    • Developing Server-Side Eclipse applications
    • Deploying Server-Side Eclipse applications
    • Monitoring and Debugging Server-Side Eclipse
      applications
    • Summary




         Building Server-Side Eclipse based web applications | Tutorial
         © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
3        Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
What is Server-Side Eclipse (SSE)?
    • Recognition… that many of the features that have made RCP successful are
     equally applicable in server-side contexts.
          Standardized component model (OSGi)
          Pervasive extensibility – Extension Registry
          Runtime provisioning


    • Integration... with existing server-side infrastructure and technologies
          J2EE Application Servers
          Servlets and JSPs
          Application Frameworks



    • The top level project Eclipse Runtime is an umbrella project for a lot of
      server-related projects



            Building Server-Side Eclipse based web applications | Tutorial
            © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
4           Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
What motivates developers to use SSE?
       Web developer                                       RCP developer                                Infrastructure developer
         JavaTM EE                                              RCP                                                 application
         application                                          application                                           framework

       + component model        + server support                                                                + component model
       + use 3rd party plug-ins + re-use plugins                                                                   • modular
                                + distributed                                                                      • flexible
                                  applications                                                                     • dynamic




        Building Server-Side Eclipse based web applications | Tutorial
        © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
5       Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
SSE Based Web Applications
    • Component based (Bundles)

    • Use the OSGi HttpService (Servlet API)
        Explicitly (code) or declaratively (extension registry)


    • Consistent development story independent of
      deployment constraints
        Support for an embedded HttpService
        Support for running embedded in Application Servers



         Building Server-Side Eclipse based web applications | Tutorial
         © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
6        Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Overview
    • Introduction to Server-Side Eclipse
    • Developing Server-Side Eclipse applications
    • Deploying Server-Side Eclipse applications
    • Monitoring and Debugging Server-Side Eclipse
      applications
    • Summary




         Building Server-Side Eclipse based web applications | Tutorial
         © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
7        Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Integrating Java EE with the OSGi HttpService
• Replaces web deploy descriptor (e.g. “web.xml”)
• URL mapping differences
• Servlet API support
     ServletContext / HttpContext differences
     Does not provide “direct” support for Filters, Listeners.
• Dynamic Registration
  void registerResources(String alias, String name, HttpContext context)
  void registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context)
  void unregister(String alias)


  Supported in Equinox:
  void registerFilter(String alias, Filter filter, Dictionary initparams, HttpContext context)
  void unregisterFilter(Filter filter)



       Building Server-Side Eclipse based web applications | Tutorial
       © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
       Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
URL Mapping Differences
void registerResources(String alias, String name, HttpContext context)

• “alias” roughly equivalent to <url-mapping>
      alias of “/myContent” is equivalent to
      <url-mapping>
          /myContent/*
      </url-mapping>


• “name” provides a base path when looking up resources in the
  HttpContext.
                                                                                                Supported in Equinox

• No support for extension mappings                                                             Syntax is:
                                                                                                                    {path}/*.jsp
• No implicit welcome file support
      eg. mapping “/” to “/index.html”



       Building Server-Side Eclipse based web applications | Tutorial
       © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
       Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
HttpContext
• Maps 1-1 to a ServletContext                                              Method Summary

                                                                            String getMimeType(String name)
• Allows implementation of custom
  HttpContext
                                                                            URL getResource(String name)

• MIME type retrieval                                                       boolean handleSecurity(
• resource retrieval                                                          HttpServletRequest request,
                                                                              HttpServletResponse response)
• authentication

• Does not directly support:                                                     Supported in Equinox (via Reflection)
     getNamedDispatcher
     getResourcePaths                                                            Set getResourcePaths(String path)
     getInitParameters (*)
     “Context Path” (*)


       Building Server-Side Eclipse based web applications | Tutorial
       © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
       Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Servlets and Filters
What’s missing…                                                                 (*) = Workarounds Available:

• Filter                                                                        • Technique is to wrap-and-adapt your
           now fully supported in Helios                                          Servlet or Resource.
                                                                                    Servlet wrapped = new
• HttpSessionListener                                                               ContextListenerServletAdaptor(
                                                                                       myServlet, myListener);
• HttpSessionAttributeListener                                                      registerServlet(“/myPath”, wrapped,
                                                                                    params, myHttpContext);
• HttpSessionActivationListener
                                                                                • org.eclipse.equinox.http.helper[s]
• ServletContextListener (*)                                                                  in the Equinox-Incubator CVS
• ServletContextAttributeListener                                                             not currently API but supported



• ServletRequestListener
• ServletRequestAttributeListener


           Building Server-Side Eclipse based web applications | Tutorial
           © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
           Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Dynamic Registration
• Code-based
      Lifecycle: tied to Bundle START and STOP
      More Complex but provides greater control

• Extension Registry (org.eclipse.equinox.http.registry)
      Lifecycle: tied to Bundle RESOLVED and UNRESOLVED
      Simpler in most cases

• Declarative Services
      Lifecycle: tied to Bundle START and STOP
      Requires writing a component file

URL Space is also dynamic and shared across all registrations
      No more than one registration per “alias”
      Worth planning – useful techniques with relative URLs


       Building Server-Side Eclipse based web applications | Tutorial
       © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
       Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
JSP Support
• Provided by:
    org.eclipse.equinox.jsp.jasper.JspServlet


<< public JspServlet(Bundle bundle, String bundleResourcePath, String alias) >>



• No default constructor
      Requires compilation / runtime context from “bundle”


• JSP lookup consistent with OSGi HttpService resource
  registration.


        Building Server-Side Eclipse based web applications | Tutorial
        © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
        Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
JSP Support – Extension Registry
• Extension Registry Support provided by:
  org.eclipse.equinox.jsp.jasper.registry.JspFactory
• ExecutableExtensionFactory
 <extension point="org.eclipse.equinox.http.registry.servlets">
  <servlet
     alias="/myPath/*.jsp“
     class="org.eclipse.equinox.jsp.jasper.registry.JSPFactory:/bundlePath">
  </servlet>
 </extension>




• Use “{path}/*.jsp” style alias for JSPs.
       Allows a “{path}” resource registration to support more efficiently serving
       static resources without an alias namespace collision.




         Building Server-Side Eclipse based web applications | Tutorial
         © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
         Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Exercises
     • Start Eclipse & configure target platform
     • Hello Servlet
     • Hello Filter
     • Hello JSP
     • Hello Servlet Registry
     • Hello Filter Registry
     • Hello JSP Registry




          Building Server-Side Eclipse based web applications | Tutorial
          © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
15        Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Overview
     • Introduction to Server-Side Eclipse
     • Developing Server-Side Eclipse applications
     • Deploying Server-Side Eclipse applications
     • Monitoring and Debugging Server-Side Eclipse
       applications
     • Summary




          Building Server-Side Eclipse based web applications | Tutorial
          © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
16        Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Recommended deployment scenarios
     Deployment depends on target infrastructure:

     • Standalone Equinox server application
         Embedded HttpService
         Lightweight solution – good choice for development
         Distribute like Eclipse RCP application


     • Run application in External Application Server
         Recommended as production solution
         Deploy as standard WAR application (scripts provided)


          Building Server-Side Eclipse based web applications | Tutorial
          © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
17        Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Equinox embedding an HttpService
     •   Run Equinox as standalone application
     •   Multiple processes isolated
     •   Embedded HttpService (e.g. Jetty)
     •   Application functionality based on bundles, Servlets, JSPs, ...
     •   Add web services as bundle
     •   Server management based on bundles




                                                                        Source: Jeff McAffer, Eclipse Summit Europe, Server-Side Symposium, Oct 12nd 2006



              Building Server-Side Eclipse based web applications | Tutorial
              © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
18            Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Deploying standalone Equinox server
                • Choose target platform
                • Add platform specific launchers if required
                • Add common services and bundles (see Eclipse Orbit!)
                • Add application plug-ins
                • Group bundles / plug-ins as features
                  Servlet                JSP                   Bundles                      ...                      ...                  Application plug-ins

                                                                                                                                          Common services
     Launcher




                                                             commons-                                           Update
                   Jetty               Jasper                                           3rdParty
                                                             logging, ...                                     Configurator                (see Orbit)
                                                             Equinox                                                                      Server-Side Eclipse

                                                    Operating System

                       Building Server-Side Eclipse based web applications | Tutorial
                       © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
19                     Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Deploying Standalone Equinox server
     • Deploy like an RCP application
           Plugins / Feature / Product based export
           You have to include SSE related plugins
           Maintain config.ini for starting bundles
     • Important config.ini settings:
           osgi.console=true                                                         # start an OSGi console
           osgi.noShutdown=true                                                      # do NOT shutdown OSGi
           eclipse.ignoreApp=true                                                    # do NOT start an Eclipse application
     • Or use commandline arguments when using Eclipse starter:
           -console                                                                  # enable OSGi console
           -noExit                                                                   # same as osgi.noShutdown=true




             Building Server-Side Eclipse based web applications | Tutorial
             © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
20           Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Deploy Standard Equinox – Running the Server
     • Start Equinox server
     java –Dorg.osgi.service.http.port=8080 
          –jar pluginsorg.eclipse.equinox.launcher_<version>.jar 
          –console -noExit




            Building Server-Side Eclipse based web applications | Tutorial
            © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
21          Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Application Server running an embedded Equinox
     • Launch Equinox in traditional application server
     • Isolation between multiple web applications/Equinox instances
     • Forwarding (Lite) HttpService exposes application server
       capabilities
     • Application functionality based on bundles, Servlets, JSPs, ...
     • Bridging aspect is referred to as the Servletbridge

                                         Servlet          JSP                                            Servlet          JSP

                   Bundles        Servletbridge HTTP Service                       Bundles        Servletbridge HTTP Service


                                     Equinox                                                         Equinox

                               Equinox WAR                              …                      Equinox WAR
                                  Bridge Servlet                                                  Bridge Servlet


                                                                 App Server

                                                                        OS

            Building Server-Side Eclipse based web applications | Tutorial
            © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
22          Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
What is the Servletbridge?
                  … a bridge between the servlet and OSGi world

     Servlet - side                                                                        OSGi - side
     • Eclipse framework launcher                                                          • Proxy Servlet that registers with
     • Bridge Servlet with a call-back                                                       Bridge Servlet
       registration point                                                                  • OSGi HttpService

                                                                 1                           5
                           Bridge Servlet                                                               Proxy Servlet

                                            2                  Servlet              OSGi                                4

                                                                        3
                    Framework Launcher                                                                    HttpService




              Building Server-Side Eclipse based web applications | Tutorial
              © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
23            Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
What is the Servletbridge?
                                               Servlet               OSGi




     Incoming Request                                                                                Registered Request Handler
                                                 Servletbridge
                                                                                                     OSGi HttpService
                                                                                                               registerResource(…)
                                                                                                               registerServlet(…)




          Incoming requests are “proxied” through the
          Servletbridge to registered request handlers.



              Building Server-Side Eclipse based web applications | Tutorial
              © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
24            Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Deploying Equinox Inside an Application Server
     • Deploy similar to an RCP application but in a Web Archive
     /WEB-INF
       /launch.ini
           (contains framework properties that will allow override of any eclipse specific System
       Properties)
       /web.xml
           (with one servlet entry assigning all incoming requests to the BridgeServlet)
       /lib/org.eclipse.equinox.servletbridge_<version>.jar
           (the classes associated with the equinox.servletbridge)
       /configuration
           (contains config.ini which lists the bundles you want to have available at startup)
       /features
       /plugins

     • Uses the PDE Product Export Wizard
             Uncheck “The product includes native launcher artifacts” and select “Eclipse
             Product Export Wizard”
             Set the “root directory” to WEB-INF and press “Finish”
             For sample products see:
                      org.eclipse.equinox.server.examples.servletbridge.product
                                server.core.product (Basic Servletbridge Product)
                                server.core.p2.product (Servletbridge Product with p2 support for provisioning)



              Building Server-Side Eclipse based web applications | Tutorial
              © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
25            Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Deploying Equinox inside Application Server
     • Online Demo




          Building Server-Side Eclipse based web applications | Tutorial
          © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
26        Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Exercises
     • Export standalone server using product export
     • Create & deploy WAR file using Servlet bridge




          Building Server-Side Eclipse based web applications | Tutorial
          © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
27        Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Overview
     • Introduction to Server-Side Eclipse
     • Developing Server-Side Eclipse applications
     • Deploying Server-Side Eclipse applications
     • Monitoring and Debugging Server-Side Eclipse
       applications
     • Summary




          Building Server-Side Eclipse based web applications | Tutorial
          © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
28        Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Logging in Equinox Jetty 6 Integration
     • Jetty logging controllable in 3.5+

     • -Dorg.eclipse.equinox.http.jetty.log.stderr.threshold=<level>

          "debug", "info", "warn", "error", and "off“
          Default is “warn”


     • Log will happen to STDERR only (for now)

     • Outlook: deeper integration with Extended Equinox
       Log Service (3.7)


            Building Server-Side Eclipse based web applications | Tutorial
            © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
29          Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Debugging: Where to hook in
     • Hook either in
         OSGi world
         ServetBridge
     • Startup problems:
         FrameworkLauncher
     • Central access:
       ProxyServlet
         Hook in processAlias


          Building Server-Side Eclipse based web applications | Tutorial
          © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
30        Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Servlet Bridge Management Commands

     “web.xml” allows configuration of initial parameters:
     • commandLine Allows all non-VM command line parameterizations of Eclipse.
       The default value is "-console“ which should be cleared for production.
     • enableFrameworkControls (true / false) - Controls whether or not the sp_* control URLs are
       accessible
            sp_deploy - Copies the contents of /platform to the install area (the servlet context tempdir is used -
            parameterizable someday)
            sp_undeploy - Removes the copy of Eclipse from the install area
            sp_redeploy - Resets the platform (e.g. stops, undeploys, deploys, starts)
            sp_start - Starts a deployed platform
            sp_stop - Stops the platform
            sp_test - Provides a sanity check and determines if an OSGi based servlet is ready to accept requests
     • frameworkLauncherClass – allows customization of the launcher
     • extendedFrameworkExports – additional java package exports from the web application.
       Servlet API is automatically exported.




              Building Server-Side Eclipse based web applications | Tutorial
              © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
31            Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Knopflerfish HTTP Console
     • Provides convenient way to manage bundles at
       runtime
     • Works within Servlet Bridge




          Building Server-Side Eclipse based web applications | Tutorial
          © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
32        Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Overview
     • Introduction to Server-Side Eclipse
     • Developing Server-Side Eclipse applications
     • Deploying Server-Side Eclipse applications
     • Monitoring and Debugging Server-Side Eclipse
       applications
     • Summary




          Building Server-Side Eclipse based web applications | Tutorial
          © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
33        Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Summary - Looking forward...
     • Eclipse >3.3 supports building OSGi based web applications for:
          Equinox based RCP and headless applications
          Equinox embedded in an application server

     • Outlook for Eclipse 3.7
          Jetty 7
          JSP 2.1

     • New Specifications from OSGi Enterprise Expert Group
          OSGi Web Container (RFC 66)
          JNDI and OSGi Integration (RFC 142)




           Building Server-Side Eclipse based web applications | Tutorial
           © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
34         Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
OSGi Web Container (RFC 66)
•   New concept… “Web Application Bundle”
•   Includes a “web.xml” in the bundle
•   Same deployment model and same features as current web
    applications
•   …but is a real bundle that can use OSGi Services

•   Syntactic sugar? Tasty?




       Building Server-Side Eclipse based web applications | Tutorial
       © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
       Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
JNDI and OSGi Integration (RFC 142)
•   Current JNDI implementations use Context Class Loader for
    lookup.

•   Clever Idiom?
    ClassLoader original = Thread.currentThread().getContextClassLoader();
    try {
         Thread.currentThread().setContextClassLoader(BridgeServlet.class.getClassLoader());
         // Do JNDI Calls here
    } finally {
         Thread.currentThread().setContextClassLoader(original);
    }



•   JNDI Service will provide a more sensible “bundle” scoped
    lookup.




         Building Server-Side Eclipse based web applications | Tutorial
         © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
         Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
For more information...
     Project hub:
      http://www.eclipse.org/equinox/server

     Newsgroup:
      news://news.eclipse.org/eclipse.technology.equinox

     Dev Mailing List:
      equinox-dev@eclipse.org

                                                            Thank-you


          Building Server-Side Eclipse based web applications | Tutorial
          © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
37        Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
Legal Notices
     • Java and all Java-based trademarks are trademarks of Sun
       Microsystems, Inc. in the United States, other countries, or both

     • Microsoft, Windows, Windows NT, and the Windows logo are trademarks
       of Microsoft Corporation in the United States, other countries, or both.

     • Linux is a registered trademark of Linus Torvalds in the United States,
       other countries, or both.

     • Other company, product, or service names may be trademarks or service
       marks of others




            Building Server-Side Eclipse based web applications | Tutorial
            © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation;
38          Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license

More Related Content

Building Server-Side Eclipse based web applications 2010

  • 1. Building Server-Side Eclipse based web applications Tutorial Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 1 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 2. The authors Jochen Hiller Simon Kaegi Deutsche Telekom AG, Germany IBM Rational Software, Canada jo.hiller@googlemail.com simon_kaegi@ca.ibm.com Equinox, e4 Committer Gunnar Wagenknecht AGETO, Germany gunnar@wagenknecht.org Eclipse Committer Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 2 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 3. Overview • Introduction to Server-Side Eclipse • Developing Server-Side Eclipse applications • Deploying Server-Side Eclipse applications • Monitoring and Debugging Server-Side Eclipse applications • Summary Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 3 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 4. What is Server-Side Eclipse (SSE)? • Recognition… that many of the features that have made RCP successful are equally applicable in server-side contexts. Standardized component model (OSGi) Pervasive extensibility – Extension Registry Runtime provisioning • Integration... with existing server-side infrastructure and technologies J2EE Application Servers Servlets and JSPs Application Frameworks • The top level project Eclipse Runtime is an umbrella project for a lot of server-related projects Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 4 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 5. What motivates developers to use SSE? Web developer RCP developer Infrastructure developer JavaTM EE RCP application application application framework + component model + server support + component model + use 3rd party plug-ins + re-use plugins • modular + distributed • flexible applications • dynamic Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 5 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 6. SSE Based Web Applications • Component based (Bundles) • Use the OSGi HttpService (Servlet API) Explicitly (code) or declaratively (extension registry) • Consistent development story independent of deployment constraints Support for an embedded HttpService Support for running embedded in Application Servers Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 6 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 7. Overview • Introduction to Server-Side Eclipse • Developing Server-Side Eclipse applications • Deploying Server-Side Eclipse applications • Monitoring and Debugging Server-Side Eclipse applications • Summary Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 7 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 8. Integrating Java EE with the OSGi HttpService • Replaces web deploy descriptor (e.g. “web.xml”) • URL mapping differences • Servlet API support ServletContext / HttpContext differences Does not provide “direct” support for Filters, Listeners. • Dynamic Registration void registerResources(String alias, String name, HttpContext context) void registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context) void unregister(String alias) Supported in Equinox: void registerFilter(String alias, Filter filter, Dictionary initparams, HttpContext context) void unregisterFilter(Filter filter) Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 9. URL Mapping Differences void registerResources(String alias, String name, HttpContext context) • “alias” roughly equivalent to <url-mapping> alias of “/myContent” is equivalent to <url-mapping> /myContent/* </url-mapping> • “name” provides a base path when looking up resources in the HttpContext. Supported in Equinox • No support for extension mappings Syntax is: {path}/*.jsp • No implicit welcome file support eg. mapping “/” to “/index.html” Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 10. HttpContext • Maps 1-1 to a ServletContext Method Summary String getMimeType(String name) • Allows implementation of custom HttpContext URL getResource(String name) • MIME type retrieval boolean handleSecurity( • resource retrieval HttpServletRequest request, HttpServletResponse response) • authentication • Does not directly support: Supported in Equinox (via Reflection) getNamedDispatcher getResourcePaths Set getResourcePaths(String path) getInitParameters (*) “Context Path” (*) Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 11. Servlets and Filters What’s missing… (*) = Workarounds Available: • Filter • Technique is to wrap-and-adapt your now fully supported in Helios Servlet or Resource. Servlet wrapped = new • HttpSessionListener ContextListenerServletAdaptor( myServlet, myListener); • HttpSessionAttributeListener registerServlet(“/myPath”, wrapped, params, myHttpContext); • HttpSessionActivationListener • org.eclipse.equinox.http.helper[s] • ServletContextListener (*) in the Equinox-Incubator CVS • ServletContextAttributeListener not currently API but supported • ServletRequestListener • ServletRequestAttributeListener Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 12. Dynamic Registration • Code-based Lifecycle: tied to Bundle START and STOP More Complex but provides greater control • Extension Registry (org.eclipse.equinox.http.registry) Lifecycle: tied to Bundle RESOLVED and UNRESOLVED Simpler in most cases • Declarative Services Lifecycle: tied to Bundle START and STOP Requires writing a component file URL Space is also dynamic and shared across all registrations No more than one registration per “alias” Worth planning – useful techniques with relative URLs Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 13. JSP Support • Provided by: org.eclipse.equinox.jsp.jasper.JspServlet << public JspServlet(Bundle bundle, String bundleResourcePath, String alias) >> • No default constructor Requires compilation / runtime context from “bundle” • JSP lookup consistent with OSGi HttpService resource registration. Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 14. JSP Support – Extension Registry • Extension Registry Support provided by: org.eclipse.equinox.jsp.jasper.registry.JspFactory • ExecutableExtensionFactory <extension point="org.eclipse.equinox.http.registry.servlets"> <servlet alias="/myPath/*.jsp“ class="org.eclipse.equinox.jsp.jasper.registry.JSPFactory:/bundlePath"> </servlet> </extension> • Use “{path}/*.jsp” style alias for JSPs. Allows a “{path}” resource registration to support more efficiently serving static resources without an alias namespace collision. Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 15. Exercises • Start Eclipse & configure target platform • Hello Servlet • Hello Filter • Hello JSP • Hello Servlet Registry • Hello Filter Registry • Hello JSP Registry Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 15 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 16. Overview • Introduction to Server-Side Eclipse • Developing Server-Side Eclipse applications • Deploying Server-Side Eclipse applications • Monitoring and Debugging Server-Side Eclipse applications • Summary Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 16 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 17. Recommended deployment scenarios Deployment depends on target infrastructure: • Standalone Equinox server application Embedded HttpService Lightweight solution – good choice for development Distribute like Eclipse RCP application • Run application in External Application Server Recommended as production solution Deploy as standard WAR application (scripts provided) Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 17 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 18. Equinox embedding an HttpService • Run Equinox as standalone application • Multiple processes isolated • Embedded HttpService (e.g. Jetty) • Application functionality based on bundles, Servlets, JSPs, ... • Add web services as bundle • Server management based on bundles Source: Jeff McAffer, Eclipse Summit Europe, Server-Side Symposium, Oct 12nd 2006 Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 18 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 19. Deploying standalone Equinox server • Choose target platform • Add platform specific launchers if required • Add common services and bundles (see Eclipse Orbit!) • Add application plug-ins • Group bundles / plug-ins as features Servlet JSP Bundles ... ... Application plug-ins Common services Launcher commons- Update Jetty Jasper 3rdParty logging, ... Configurator (see Orbit) Equinox Server-Side Eclipse Operating System Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 19 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 20. Deploying Standalone Equinox server • Deploy like an RCP application Plugins / Feature / Product based export You have to include SSE related plugins Maintain config.ini for starting bundles • Important config.ini settings: osgi.console=true # start an OSGi console osgi.noShutdown=true # do NOT shutdown OSGi eclipse.ignoreApp=true # do NOT start an Eclipse application • Or use commandline arguments when using Eclipse starter: -console # enable OSGi console -noExit # same as osgi.noShutdown=true Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 20 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 21. Deploy Standard Equinox – Running the Server • Start Equinox server java –Dorg.osgi.service.http.port=8080 –jar pluginsorg.eclipse.equinox.launcher_<version>.jar –console -noExit Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 21 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 22. Application Server running an embedded Equinox • Launch Equinox in traditional application server • Isolation between multiple web applications/Equinox instances • Forwarding (Lite) HttpService exposes application server capabilities • Application functionality based on bundles, Servlets, JSPs, ... • Bridging aspect is referred to as the Servletbridge Servlet JSP Servlet JSP Bundles Servletbridge HTTP Service Bundles Servletbridge HTTP Service Equinox Equinox Equinox WAR … Equinox WAR Bridge Servlet Bridge Servlet App Server OS Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 22 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 23. What is the Servletbridge? … a bridge between the servlet and OSGi world Servlet - side OSGi - side • Eclipse framework launcher • Proxy Servlet that registers with • Bridge Servlet with a call-back Bridge Servlet registration point • OSGi HttpService 1 5 Bridge Servlet Proxy Servlet 2 Servlet OSGi 4 3 Framework Launcher HttpService Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 23 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 24. What is the Servletbridge? Servlet OSGi Incoming Request Registered Request Handler Servletbridge OSGi HttpService registerResource(…) registerServlet(…) Incoming requests are “proxied” through the Servletbridge to registered request handlers. Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 24 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 25. Deploying Equinox Inside an Application Server • Deploy similar to an RCP application but in a Web Archive /WEB-INF /launch.ini (contains framework properties that will allow override of any eclipse specific System Properties) /web.xml (with one servlet entry assigning all incoming requests to the BridgeServlet) /lib/org.eclipse.equinox.servletbridge_<version>.jar (the classes associated with the equinox.servletbridge) /configuration (contains config.ini which lists the bundles you want to have available at startup) /features /plugins • Uses the PDE Product Export Wizard Uncheck “The product includes native launcher artifacts” and select “Eclipse Product Export Wizard” Set the “root directory” to WEB-INF and press “Finish” For sample products see: org.eclipse.equinox.server.examples.servletbridge.product server.core.product (Basic Servletbridge Product) server.core.p2.product (Servletbridge Product with p2 support for provisioning) Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 25 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 26. Deploying Equinox inside Application Server • Online Demo Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 26 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 27. Exercises • Export standalone server using product export • Create & deploy WAR file using Servlet bridge Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 27 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 28. Overview • Introduction to Server-Side Eclipse • Developing Server-Side Eclipse applications • Deploying Server-Side Eclipse applications • Monitoring and Debugging Server-Side Eclipse applications • Summary Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 28 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 29. Logging in Equinox Jetty 6 Integration • Jetty logging controllable in 3.5+ • -Dorg.eclipse.equinox.http.jetty.log.stderr.threshold=<level> "debug", "info", "warn", "error", and "off“ Default is “warn” • Log will happen to STDERR only (for now) • Outlook: deeper integration with Extended Equinox Log Service (3.7) Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 29 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 30. Debugging: Where to hook in • Hook either in OSGi world ServetBridge • Startup problems: FrameworkLauncher • Central access: ProxyServlet Hook in processAlias Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 30 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 31. Servlet Bridge Management Commands “web.xml” allows configuration of initial parameters: • commandLine Allows all non-VM command line parameterizations of Eclipse. The default value is "-console“ which should be cleared for production. • enableFrameworkControls (true / false) - Controls whether or not the sp_* control URLs are accessible sp_deploy - Copies the contents of /platform to the install area (the servlet context tempdir is used - parameterizable someday) sp_undeploy - Removes the copy of Eclipse from the install area sp_redeploy - Resets the platform (e.g. stops, undeploys, deploys, starts) sp_start - Starts a deployed platform sp_stop - Stops the platform sp_test - Provides a sanity check and determines if an OSGi based servlet is ready to accept requests • frameworkLauncherClass – allows customization of the launcher • extendedFrameworkExports – additional java package exports from the web application. Servlet API is automatically exported. Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 31 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 32. Knopflerfish HTTP Console • Provides convenient way to manage bundles at runtime • Works within Servlet Bridge Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 32 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 33. Overview • Introduction to Server-Side Eclipse • Developing Server-Side Eclipse applications • Deploying Server-Side Eclipse applications • Monitoring and Debugging Server-Side Eclipse applications • Summary Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 33 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 34. Summary - Looking forward... • Eclipse >3.3 supports building OSGi based web applications for: Equinox based RCP and headless applications Equinox embedded in an application server • Outlook for Eclipse 3.7 Jetty 7 JSP 2.1 • New Specifications from OSGi Enterprise Expert Group OSGi Web Container (RFC 66) JNDI and OSGi Integration (RFC 142) Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 34 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 35. OSGi Web Container (RFC 66) • New concept… “Web Application Bundle” • Includes a “web.xml” in the bundle • Same deployment model and same features as current web applications • …but is a real bundle that can use OSGi Services • Syntactic sugar? Tasty? Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 36. JNDI and OSGi Integration (RFC 142) • Current JNDI implementations use Context Class Loader for lookup. • Clever Idiom? ClassLoader original = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(BridgeServlet.class.getClassLoader()); // Do JNDI Calls here } finally { Thread.currentThread().setContextClassLoader(original); } • JNDI Service will provide a more sensible “bundle” scoped lookup. Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 37. For more information... Project hub: http://www.eclipse.org/equinox/server Newsgroup: news://news.eclipse.org/eclipse.technology.equinox Dev Mailing List: equinox-dev@eclipse.org Thank-you Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 37 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license
  • 38. Legal Notices • Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both • Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in the United States, other countries, or both. • Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both. • Other company, product, or service names may be trademarks or service marks of others Building Server-Side Eclipse based web applications | Tutorial © Copyright 2007, 2008, 2009, 2010 Jochen Hiller, Simon Kaegi, Gunnar Wagenknecht, IBM Corporation; 38 Source code in this presentation is made available under the EPL, v1.0, remainder of the presentation is licensed under Creative Commons Att. Nc Nd 2.5 license