Record Class RestContext.Args

java.lang.Object
java.lang.Record
org.apache.juneau.rest.server.RestContext.Args
Record Components:
resourceClass - The @Rest-annotated REST resource class. Must not be null.
parentContext - The parent RestContext, or null if this is a top-level resource.
servletConfig - The ServletConfig from the servlet container, or null when none is available.
resource - The supplier that provides the resource instance during initialization. Must not be null.
path - The path prefix relative to the parent. Defaults to "".
beanStoreConfigurer - A pre-build hook that runs against the resolved WritableBeanStore after the resource has been wired in but before any findXxx() memoizer fires. Defaults to a no-op.
overridingParent - An optional test-time override layer installed into the overridingParent slot of the freshly-constructed BasicBeanStore. May be null. Honored only when the resource does not declare an @Bean WritableBeanStore factory method; user-supplied bean stores are passed through unchanged.
paths - An optional programmatic override for the top-level mount-paths array (the highest-priority rung in the runtime-override chain documented on RestContext.getPaths()). null (the default) means "no programmatic override" — resolution falls through to the resource's getPaths() getter, then Rest.paths() (SVL-resolved per element and comma-split). An empty array explicitly clears the mount list (no top-level mounts).
kind - The build-time kind of this context — ROOT for a top-level/host/mock resource, a CHILD carrying the RestContext.ResolvedChild for a @Rest(children)/childrenDefs sub-resource (isolated resolution, with an optional host-seeded payload), or a MIXIN carrying the RestContext.ResolvedMixin that produced a per-mixin sub-context (parent-linked to the host so that annotation-property walks prepend the host's @Rest chain before the mixin's own).
Enclosing class:
RestContext

public static record RestContext.Args(Class<?> resourceClass, RestContext parentContext, jakarta.servlet.ServletConfig servletConfig, Supplier<?> resource, String path, Consumer<WritableBeanStore> beanStoreConfigurer, BeanStore overridingParent, String[] paths, RestContext.ContextKind kind, RestBuilder<?> restBuilder) extends Record
Bootstrap arguments for RestContext.

Bundles the small, fixed set of inputs needed to construct a RestContext into a single immutable record.

All non-required values default sensibly:

  • parentContext, servletConfig — null (top-level resource, no servlet container)
  • path — "" (no path prefix)
  • beanStoreConfigurer — no-op (no pre-build bean-store mutation)
  • overridingParent — null (no test-time override layer)

The beanStoreConfigurer hook gives test fixtures and integration code a chance to register beans on the WritableBeanStore after the resource has been wired in but before the findXxx() memoizers fire.

The overridingParent hook installs a BeanStore into the overridingParent slot of the freshly-constructed BasicBeanStore so that test-time overrides resolve at tier 1 of the lookup chain (above the resource's local @Bean factory entries and the Spring bridge). This is the canonical Mode INJECT wiring point for juneau-junit5's TestBeanStore.

Example:

var ctx = new RestContext(new RestContext.Args(MyResource.class, () -> new MyResource()));

Since:
10.0.0
  • Constructor Details

    • Args

      public Args(Class<?> resourceClass, RestContext parentContext, jakarta.servlet.ServletConfig servletConfig, Supplier<?> resource, String path, Consumer<WritableBeanStore> beanStoreConfigurer, BeanStore overridingParent, String[] paths, RestContext.ContextKind kind, RestBuilder<?> restBuilder)
      Compact canonical constructor — null-coalesces optional fields and validates required ones.
    • Args

      public Args(Class<?> resourceClass, RestContext parentContext, jakarta.servlet.ServletConfig servletConfig, Supplier<?> resource, String path, Consumer<WritableBeanStore> beanStoreConfigurer, BeanStore overridingParent, String[] paths, RestContext.ContextKind kind)
      Back-compatible constructor without the restBuilder component (defaults it to null).

      The restBuilder is then resolved during RestContext construction from the resource instance's stashed builder, so call sites that don't carry one keep working unchanged.

      Parameters:
      resourceClass - The resource class.
      parentContext - The parent context, or null.
      servletConfig - The servlet config, or null.
      resource - The resource supplier.
      path - The mount path override, or null.
      beanStoreConfigurer - The bean-store configurer, or null.
      overridingParent - The overriding parent bean store, or null.
      paths - The programmatic mount-paths override, or null.
      kind - The build-time kind of this context, or null for RestContext.ContextKind.ROOT.
  • Method Details

    • isMixinContext

      public boolean isMixinContext()
      Returns true when this context is a per-mixin sub-context (its kind() is a RestContext.ContextKind.Mixin).
      Returns:
      true for a mixin sub-context.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • resourceClass

      public Class<?> resourceClass()
      Returns the value of the resourceClass record component.
      Returns:
      the value of the resourceClass record component
    • parentContext

      Returns the value of the parentContext record component.
      Returns:
      the value of the parentContext record component
    • servletConfig

      public jakarta.servlet.ServletConfig servletConfig()
      Returns the value of the servletConfig record component.
      Returns:
      the value of the servletConfig record component
    • resource

      public Supplier<?> resource()
      Returns the value of the resource record component.
      Returns:
      the value of the resource record component
    • path

      public String path()
      Returns the value of the path record component.
      Returns:
      the value of the path record component
    • beanStoreConfigurer

      Returns the value of the beanStoreConfigurer record component.
      Returns:
      the value of the beanStoreConfigurer record component
    • overridingParent

      Returns the value of the overridingParent record component.
      Returns:
      the value of the overridingParent record component
    • paths

      public String[] paths()
      Returns the value of the paths record component.
      Returns:
      the value of the paths record component
    • kind

      Returns the value of the kind record component.
      Returns:
      the value of the kind record component
    • restBuilder

      public RestBuilder<?> restBuilder()
      Returns the value of the restBuilder record component.
      Returns:
      the value of the restBuilder record component