Class NavigationMixin

java.lang.Object
org.apache.juneau.rest.server.servlet.RestMixin
org.apache.juneau.rest.server.ops.NavigationMixin

public class NavigationMixin extends RestMixin
Mixin providing the group-navigation endpoint ([GET /]) that lists the host resource's child resources.

Single-responsibility op-mixin carved out of the former BasicGroupOperations interface (and the concrete getChildren(...) method previously kept on the Basic*Group base classes). The navigation page renders one entry per @Rest(children) resource declared on the host.

Reaching the host's children:

A mixin's @RestOp methods are bound to a per-mixin RestContext sub-context that has no children of its own, so this op resolves the host's children via getHostContext().getRestChildren() rather than against the mixin's own (empty) context. Because getHostContext() is backed by the sub-context's already-populated parent linkage, this works whether the mixin is composed onto a servlet host or a child-resource host.

Page decoration:

Per the mixin sub-context inheritance model, the navigation page inherits the host's class-level @HtmlDocConfig page decoration (navigation links, etc.), so the rendered HTML matches the host's other endpoints.

Composition example:

@Rest(mixins=NavigationMixin.class, children={Foo.class, Bar.class}) public class RootResource extends RestServlet { ... }

See Also:
Since:
10.0.0
  • Constructor Details

    • NavigationMixin

      public NavigationMixin()
      No-arg constructor — navigation has no configurable state.
  • Method Details

    • getChildren

      [GET /] - Get child resources.

      Returns a bean that lists and allows navigation to the host resource's child resources, resolved against the host context so the listing reflects the host's children rather than the mixin's own (empty) sub-context.

      Parameters:
      req - The HTTP request.
      Returns:
      The bean containing links to the child resources.