what‘s new in h p service - eclipsecon north-america 2014

21
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Condential. What‘s new in Hp Service Felix Meschberger, Adobe 1 1 Dienstag, 26. März 13

Upload: others

Post on 16-Mar-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

What‘s new in H!p ServiceFelix Meschberger, Adobe

1

1Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Se"ing the Scope

2

Web Applications Speci"cation

Web Applic

ations

Support

H!p Service Speci"cation

Web Applic

ations

OSGi-sty

le

2Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

H"p Service 1.2

§ More or less unmodi!ed since OSGi R1 (May, 2000)§ Resource Registration

§ Custom Authentication

§ Based on Servlet API 2.1 (November, 1998)§ Error Pages (Servlet API 2.2)

§ Filters (Servlet API 2.3)

§ Application Events (Servlet API 2.3)

§ Limited Servlet Registration (path pre!x only)

§ Complex registration:§ Requires H"pService to register

§ Requires keeping state of successful registration

§ Requires H"p Service to unregister

3

901 San Antonio RoadPalo Alto, CA 94303 USA415 960-1300 fax 415 969-9131

A Division of Sun Microsystems, Inc.

Java™ Servlet APISpecification

Version 2.1a

James DuncanDavidsonwith Suzanne Ahmed

November 1998

Java Software Division

OSGi Service Gateway SpecificationRelease 1.0

May, 2000Copyright © The Open Services Gateway Initiative (2000). All Rights Reserved.Implementation of certain elements of the Open Services Gateway Initiative (OSGI)Specification may be subject to third party intellectual property rights, including withoutlimitation, patent rights (such a third party may or may not be a member of OSGi). OSGi isnot responsible and shall not be held responsible in any manner for identifying or failing toidentify any or all such third party intellectual property rights. This document and theinformation contained herein are provided on an "AS IS" basis and OSGI DISCLAIMSALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TOANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOTINFRINGE ANY RIGHTS AND ANY IMPLIED WARRANTIES OFMERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENTWILL OSGI BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF BUSINESS, LOSSOF USE OF DATA, INTERRUPTION OF BUSINESS, OR FOR DIRECT, INDIRECT,SPECIAL OR EXEMPLARY, INCIDENTIAL, PUNITIVE OR CONSEQUENTIALDAMAGES OF ANY KIND IN CONNECTION WITH THIS DOCUMENT OR THEINFORMATION CONTAINED HEREIN, EVEN IF ADVISED OF THE POSSIBILITYOF SUCH LOSS OR DAMAGE.

All Company, brand and product names may be trademarks that are the sole property oftheir respective owners. All rights reserved.

OSGi Service Gateway Specification Release 1.0

http://curie.eng/OSGi/index.html (1 of 2) [4/27/2000 12:29:54 PM]

3Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Where will H"p Service Go ?

§ Servlet API Version

§ Web Application Descriptor Elements

§ Simpler Registration

§ Clarify Relationship between H"pContext and ServletContext

§ Diagnostic API (based on RFC 185 / Data Transfer Objects)

4

4Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Requirements 1: H"p Service Updates

HS-1 #e solution MUST de!ne the relationship between the H"p Service and Web Application speci!cations.

HS-2 #e solution MUST update the H"p Service speci!cation to refer to the latest Servlet API speci!cation and de!ne to what extend the H"p Service provides support.

HS-3 #e solution MUST extend the H"pService service API to support Servlet registration with pa"erns as de!ned by the Servlet API speci!cation (Section 12.2, Speci!cation of Mappings, in the Servlet API 3.0 speci!cation). #is requirement aligns servlet registration to functionality provided by the Servlet API web application descriptor (web.xml).

HS-4 #e solution MUST extend the H"pService service API to support registration of Servlet API !lters with pa"erns as de!ned by the Servlet API speci!cation (Section 12.2, Speci!cation of Mappings, in the Servlet API 3.0 speci!cation) or referring to servlets by their names. #is requirement aligns mapping !lters to requests to functionality provided by the Servlet API web application descriptor (web.xml).

HS-5 #e solution MUST extend the H"pService service API to support registration of Servlet API listeners.

HS-6 #e solution MUST add support for error page con!guration.

HS-7 #e solution MUST de!ne how registered Servlets and Filters are named.

HS-8 #e solution MUST clarify ServletContext implementation in the H"pService for both standalone and bridged H"p Service implementations.

HS-9 #e solution MUST clarify the ServletContext scope of Servlet API listeners registered through the H"pService.

HS-10 #e solution MAY specify support for scripted request processing. For example supporting JSP with Tag Libraries.

HS-11 #e solution MAY de!ne how H"pService instances can be dynamically con!gured.

HS-12 #e solution MUST de!ne service registration properties for the H"pService to re$ect con!guration of the service.

5

5Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Requirements 2: Whiteboard Registration

HS-13 #e solution MUST de!ne whiteboard registration of servlet services with the H"pService.

HS-14 #e solution MUST de!ne whiteboard registration of !lter services with the H"pService.

HS-15 #e solution MUST de!ne whiteboard registration of servlet listener services with the H"pService.

HS-16 #e solution MUST de!ne registration of OSGi H"pContext services used for Servlet and Filter registration.

HS-17 #e solution MUST de!ne how servlets, !lters, and servlet listener services are matched with H"pService services for registration.

HS-18 #e solution MUST support registration of static resources according to the extender pa"ern.

HS-19 #e solution MUST support registration of error pages according to the extender pa"ern.

HS-20 #e solution MUST de!ne a capability for the osgi.extender namespace. Bundles providing resources and/or error pages can then require this capability.

HS-21 #e solution MUST de!ne a capability for the whiteboard pa"ern registration in one of the standard namespaces (or a new namespace to be de!ned in the Chapter 135, Common Namespaces Speci!cation). Bundles registering servlet, !lter, and/or servlet listener services can then require this capability.

6

6Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Servlet API Version

§ Which Servlet API to support/require ?§ Servlet API 3.0 for the latest and greatest ?

§ Must not alienate Embedded Systems !

§ Servlet API and the Platform§ 2.4 requires Java 1.3

§ 2.5 requires Java 5

§ 3.0 requires Java 6

7

>= 2.4

7Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Web Application Descriptor Elements

8

Servlet

Filter

Error Pages

Event Listener

EJB

MIME mapping

Replacements• EJB: Use Services• MIME mapping: Use HttpContext

8Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Registration - H"p Service 1.2 API

9

public interface HttpService {

public void registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context) throws ServletException, NamespaceException;

public void unregister(String alias);

}

Single path Pre!x only

Servlet or Resource ?

Manage State

Service Required

Share ?

9Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Registration - H"p Service 1.2 Example

10

@Component(service = {}, property = "alias=/")public class SampleServletOld extends HttpServlet {

private HttpService httpService;

private String servletAlias;

private boolean servletRegistered;

@Activate private void activate(Map<String, Object> config) throws ServletException, NamespaceException { this.servletAlias = (String) config.get("alias"); this.httpService.registerServlet(this.servletAlias, this, null, null); this.servletRegistered = true; }

@Deactivate private void deactivate() { if (this.servletRegistered) { this.httpService.unregister(servletAlias); } }

@Reference(unbind = "unbindHttpService") private void bindHttpService(final HttpService httpService) { this.httpService = httpService; }

private void unbindHttpService(final HttpService httpService) { if (this.httpService == httpService) { this.httpService = null; } }}

Manage State

Service Required

10Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Registration - Whiteboard Pa"ern

11

@Component(service = Servlet.class,property = "osgi.http.whiteboard.pattern=/")

public class SampleServletWhiteboard extends HttpServlet {

}

§ No H"p Service reference

§ No State Management

11Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

H"p Context and Servlet Context

12

Common Servlet Context(e.g. from Servlet Container)

Servlet Context 1 Servlet Context n

H"p Context 1 H"p Context n

Context PathLoggingVersion

A"ributesResourcesHTTP Sessions

A"ributesResources

HTTP Sessions

AuthenticationMIME Types

AuthenticationMIME Types

12Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Whiteboard Pa"ern Support Explained

§ Uses Servlet, Filter, H"pContext services

§ Registers with H"p Service

§ Matches Servlet to H"pContext with context.name property

13

Servlet

H"pContext

H"p Service

context.name

pa"ern

Filter

pa"ern

13Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

H"p Service Whiteboard Properties

14

osgi.http.whiteboard. Servlet H!pContext Filter

.pattern

.context.name

.context.shared

.errorPage

.service.target

.prefix

Registration Pa"ern

n/a Registration Pa"ern

Refers to H"pContext Identi!es

Refers to H"pContext

n/aShared across

Bundles ? n/a

Status CodeException Type n/a n/a

H"pService Selection n/a

H"pService Selection

Resource Pre!x n/a n/a

14Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Alias vs. Pa"ern

15

H!p Service Servlet API Match Type

/alias /pre!x/* Pre!x Match

*.ext Extension Match

„“ (empty) Context Root Match

/ Default Servlet

/exact/match Exact Match

§ osgi.http.whiteboard.pattern Service Registration Property

§ String+: String, String[], Collection<String>

15Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Application Events

§ Listeners are Services§ Listener interface is Service Name

§ Supported Listeners depending on Servlet API Support

§ Whiteboard Registration

§ All Events from H"p Service

§ Exception: ServletContextListener

16

16Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Diagnostic API

§ ServletDTO[] getServlets();§ Map<String, String> getResources();§ FilterDTO[] getFilters();§ Map<Object, String> getErrorLocations();

17

FilterDTO- String name;- String[] patterns;- ServletContextDTO servletContext;

ServletDTO- String name;- String[] patterns;- String servletInfo;- ServletContextDTO servletContext;

ServletContextDTO- String name;- String contextPath;- Map<String, Object> initParams;- Map<String, Object> attributes;

17Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

What else ?

§ Resources§ Replacement for HttpService.registerResources

§ org.osgi.service.http.Resource Servlet

§ osgi.http.whiteboard.pattern - String+ of URL pa"erns

§ osgi.http.whiteboard.prefix - String of name pre!x

§ H"p Service Registration Property§ osgi.http.service.endpoints - String+ of endpoint URIs, e.g. http://127.0.0.1:4502

§ Capability / Namespace§ New namespace osgi.whiteboard

§ Whiteboard Capability: osgi.http

18

Provide-Capability: osgi.whiteboard; osgi.whiteboard="osgi.http"; uses:="javax.servlet"; version:Version="1.3"

Require-Capability: osgi.whiteboard; filter:="(&(osgi.whiteboard=osgi.http)(version>=1.3))"

18Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Good News

19

© 2013 OSGi AllianceAll Rights Reserved.

OSGi Early Draft

2013.03

4 March 2013

19Dienstag, 26. März 13

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Links

§ h"p://wiki.osgi.org/wiki/WebExperience

§ OSGi Early Access Dra% 2013-03§ h"p://www.osgi.org/Download/File?url=/download/osgi-early-dra%-2013-03.pdf

§ Discuss§ mailto:[email protected]

§ OSGi Service Gateway Speci!cation Releases 1.0§ h"p://www.osgi.org/Download/Release1

§ OSGi Enterprise Release 5§ h"p://www.osgi.org/Download/Release5

20

20Dienstag, 26. März 13

1 Sign In: www.eclipsecon.org

2 Select Session Evaluate

3 Vote

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Give Feedback on the Session

21

21Dienstag, 26. März 13