Resource Classes

Now let's take a look at the resource classes themselves.
The top-level page...

http://localhost:10000

...is generated by this class...

@RestResource( path="/", title="My Microservice", description="Top-level resources page", htmldoc=@HtmlDoc( navlinks={ "options: servlet:/?method=OPTIONS" } ), children={ HelloWorldResource.class, ConfigResource.class, LogsResource.class } ) public class RootResources extends BasicRestServletJenaGroup { // No code! }

- The title and description annotations define the titles on the page.
  These can be globalized using $L{...} variables, or by defining specially-named properties in the properties file for the resource.
- In this case, the path annotation defines the context root of your application since it was not specified in the manifest or config file.
  Therefore, this resource is mapped to http://localhost:10000.
- The children annotation make up the list of child resources.
  These child resources can be anything that extends from Servlet, although usually they will be subclasses of {@link oajr.BasicRestServlet} or other resource groups.

If you click the helloWorld link in your application, you'll get a simple hello world message:

http://localhost:10000/helloWorld

...which is generated by this class...

@RestResource( path="/helloWorld", title="Hello World example", description="Simplest possible REST resource" ) public class HelloWorldResource extends BasicRestServlet { @RestMethod(name=GET, path="/*") public String sayHello() { return "Hello world!"; } }