Annotation Type RestStartCall


Identifies a method that is called immediately after the HttpServlet.service(HttpServletRequest, HttpServletResponse) method is called.

Note that you only have access to the raw request and response objects at this point.

The list of valid parameter types are as follows:

  • Servlet request/response objects:
    • HttpServletRequest
    • HttpServletResponse
Example:

@Rest(...) public class MyResource extends BasicRestServlet { // Add a request attribute to all incoming requests. @RestStartCall public void onStartCall(HttpServletRequest req) { req.setAttribute("foobar", new FooBar()); } }

Notes:
  • The method should return void although if it does return any value, the value will be ignored.
  • The method should be public although other visibilities are valid if the security manager allows it.
  • Static methods can be used.
  • Multiple start-call methods can be defined on a class.
    Start call methods on parent classes are invoked before start-call methods on child classes.
    The order of start-call method invocations within a class is alphabetical, then by parameter count, then by parameter types.
  • The method can throw any exception.
    BasicHttpExceptions can be thrown to cause a particular HTTP error status code.
    All other exceptions cause an HTTP 500 error status code.
  • Note that if you override a parent method, you probably need to call super.parentMethod(...).
    The method is still considered part of the parent class for ordering purposes even though it's overridden by the child class.
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Dynamically apply this annotation to the specified methods.