2
votes

For my app engine application, I want to assign a servlet to a url pattern, but also set up the Objectify filter as described here: https://code.google.com/p/objectify-appengine/wiki/Setup.

In my app.yaml I've got

handlers:
  - url: /v1/*
    name: v1
    servlet: org.restlet.ext.servlet.ServerServlet
    ...etc...

which is routing requests to my servlet just fine, but I can't figure out how to arrange for the Objectify filter to run on the same requests that the servlet is handling.

The GAE docs say "A filter is a class that acts on a request like a servlet, but may allow the handling of the request to continue with other filters or servlets."

OK, good, that's what I want. But the docs also say "A single URL mapping can include either a filter or a servlet, but not both."

So... how do I do this?

1

1 Answers

3
votes

Filters are run before servlets and they are not exclusive. Normally for a request all filters would run and then one servlet for given Url would be chosen and executed.

Create a new filter section in your yaml:

handlers:
  - url: /v1/*
    name: v1
    servlet: org.restlet.ext.servlet.ServerServlet
  - url: /*    
    name: ObjectifyFilter
    filter: com.googlecode.objectify.ObjectifyFilter

Note: it's best to have ObjectifyFilter run on all requests (url: /*) just to be sure that objectify is always initialised.