@RestMethod

REST Java methods are identified on REST servlets using the {@link oajr.annotation.RestMethod @RestMethod} annotation. The annotation allows the framework to identify the available REST methods through reflection.

Example:

@RestMethod(name=GET, path="/") public String sayHello() { return "Hello world!"; }

When the name and/or path values are not specified, their values are inferred from the Java method name.

The HTTP method can be inferred from the Java method by starting the method name with any of the following:

If path is not defined, it's inferred from the Java method name (minus the prefix above).

Examples:

// Method="GET", path="/foo" @RestMethod public String getFoo() {...}

// Method="DELETE", path="/foo" @RestMethod public String deleteFoo() {...}

// Method="GET", path="/foo" // "GET" is default @RestMethod public String foo() {...}

// Method="GET", path="/" @RestMethod(path="/") public String foo() {...}

// Method="GET", path="/" @RestMethod public String get() {...}

// Method="POST", path="/" @RestMethod public String post() {...}

If name and path are both specified, the Java method name can be anything.