Instantiation

REST resources are deployed in one of two ways:

- Deployed in a J2EE container as a servlet.
- Deployed as a child of another REST resource.

When deployed in a J2EE container, you MUST extend from one of the servlet classes.

When deployed as a child of another resource, you MAY extend from one of the servlet classes but it's not necessary.
The only requirement is that the class be annotated with @RestResource and have one of the following constructors:

- `public T()`
- `public T(RestContextBuilder)`

And even that requirement is relaxed if you implement your own REST resource resolver (described later).

For example:

// Top level resource is deployed like any other servlet and must subclass from RestServlet. @RestResource( path="/top", children={ ChildResource.class // Accessed via URI "/top/child" } ) public class TopLevelResource extends BasicRestServlet {...}

// Child resources can inherit from RestServlet but it's not a requirement. @RestResource( path="/child" ) public class ChildResource extends WhateverYouWant {...}

That's all there is to it! There's no code scanning, module configuration/initialization classes, or anything complex like that. It's just a servlet.