Ticket #480 (closed Enhancement: fixed)

Opened 7 years ago

Last modified 7 years ago

Additional Core Event: PRE_PROCESS_REQUEST

Reported by: jri Owned by: jri
Priority: Major Milestone: Release 4.2
Component: DeepaMehta Standard Distribution Version: 4.1
Keywords: Cc: dgf, Malte
Complexity: 2 Area: Application Framework / API
Module: deepamehta-core

Description

To be fired before a request is processed.
This is needed to let e.g. a caching plugin answer requests with a cached response.

See #478, #477.

Change History

comment:1 Changed 7 years ago by jri

  • Status changed from new to accepted

comment:2 Changed 7 years ago by jri

  • Status changed from accepted to closed
  • Resolution set to fixed

New Core Event PRE_PROCESS_REQUEST (#480, #478).

Fired before a request is processed. That is *before* a possible resource method is invoked.
This allows a plugin e.g. to abort request processing in case a pre-condition is not met (as stated e.g. by the If-Modified-Since or If-Unmodified-Since headers).

New listener interface:

de.deepamehta.core.service.event.PreProcessRequestListener?

Listener method:

void preProcessRequest(ContainerRequest? request)

Note: ContainerRequest? is a Jersey-specific class
(com.sun.jersey.spi.container.ContainerRequest?).
We should remove the Jersey dependency and move to JAX-RS 2.0 instead.

Close ticket 480.
See ticket 478.

Changeset: 0d1cf5baded3320d0520e32fd5cc1674ce77eb27

comment:3 Changed 7 years ago by jri

  • Status changed from closed to reopened
  • Resolution fixed deleted

At the moment the PRE_PROCESS_REQUEST is fired only for requests that are bound to the Jersey servlet. It should be fired for requests that access static (bundle and file system) resources as well. For that purpose the listener method should get an additional HttpServletRequest parameter.

See #448 ("Replace Felix HTTP by OPS4J Pax Web").

comment:4 Changed 7 years ago by jri

New core event: RESOURCE_REQUEST_FILTER (#480, #448).

This event allows to intercept with requests to static resources, both bundle resources and file system resources.

Listener interface: de.deepamehta.core.service.event.ResourceRequestFilterListener?
Listener method: void resourceRequestFilter(HttpServletRequest? servletRequest)

To abort request processing throw a javax.ws.rs.WebApplicationException?.
DeepaMehta will send the response wrapped in that WAE then (status code, headers, text entity).

BREAKING CHANGES

2 Core events are renamed:

PreProcessRequestListener? -> ServiceRequestFilterListener?
preProcessRequest() -> serviceRequestFilter()

PreSendResponseListener? -> ServiceResponseFilterListener?
preSendResponse() -> serviceResponseFilter()

IMPORTANT

Dropping of the Felix ExtHttpService? should be now complete. This branch could be merged into master.

In order to be nearly compatible with the (now dropped) registerFilter() method your plugin can consider implementing both, ServiceRequestFilterListener? and (the new) ResourceRequestFilterListener?. This ensures to intercept with each kind of request, that is service method requests (REST) as well as static resource requests (bundle resources and file system resources).

For the sake of completeness: the behavoir resulting from implementing both listeners is not fully equivalent as with registerFilter(). While the listeners see only requests bound to the registered URI namespaces the former servlet filter saw absolutely all requests, also the ones resulting in 404 Not Found. However, in practice this difference should not be relevant.

The Access Control plugin makes use of the new ResourceRequestFilterListener?. Thus a private DeepaMehta installation works like before, also in Safari (see #448).

See #480.

Changeset: c16c598f94f5179af050ab24b724a73d2aadece9

comment:5 Changed 7 years ago by Jörg Richter

comment:6 Changed 7 years ago by jri

  • Status changed from reopened to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.