Annotation Interface Mixin
@Rest(mixinDefs=...) attribute.
Declares a mixin class and lets the host override selected @Rest-level settings for
that mixin's mixed-in endpoints — in one place, without subclassing or editing the mixin class. This
is the host-side complement to @Rest(mixins=...) (which takes bare classes and offers
no override hook).
Example:
Here AdminGuard is applied to FooMixin's endpoints as declared by the host, without
FooMixin having to declare it.
Override semantics
The override slots mirror the same @Rest attributes and resolve through the existing host→mixin
inheritance chain, exactly as if the value had been declared on the mixin class itself, but at the
most-derived position so a host override wins over the mixin class's own same-property declaration:
- List-shaped (
guards,converters,encoders,serializers,parsers,responseProcessors,restOpArgs, default headers/attributes,produces/consumes) — appended after the host chain that the mixin inherits. - Replace-shaped (
partSerializer,partParser,defaultAccept/defaultContentType/defaultCharset,maxInput,roleGuard/rolesDeclared,messages) — the host override wins when set.
noInherit() is the @Mixin's own inheritance-cutoff list, applied to this mixin's
sub-context: a token here cuts the host→mixin inheritance walk for that property (same token set as
Rest.noInherit()). The host override is authoritative but overridable by these
noInherit rules — e.g. @Mixin(type=X.class, noInherit="guards") removes the host's
guard chain from X's endpoints entirely.
path()/paths() re-mount the mixin's endpoints under host-chosen prefix(es).
Merging a mixin's list attributes into the host
The override slots above apply the host's values to the mixin's endpoints. The separate opt-in
mergeIntoHost() directive does the reverse: it appends the mixin's own list-shaped
@Rest attributes (e.g. responseProcessors) into the host's own chains, so the host's own
@RestOp methods pick them up too. It defaults to false (host endpoints see only the host's
chain, as before) and is only settable on a rich @Mixin — see mergeIntoHost().
See Also:
- Since:
- 10.0.0
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionString[]Host-declaredconsumesoverride for this mixin's endpoints.Class<? extends RestConverter>[]Host-declaredconvertersoverride for this mixin's endpoints.Host-declareddefaultAcceptoverride for this mixin's endpoints.Host-declareddefaultCharsetoverride for this mixin's endpoints.Host-declareddefaultContentTypeoverride for this mixin's endpoints.String[]Host-declareddefaultRequestAttributesoverride for this mixin's endpoints.String[]Host-declareddefaultRequestHeadersoverride for this mixin's endpoints.String[]Host-declareddefaultResponseHeadersoverride for this mixin's endpoints.Host-declaredencodersoverride for this mixin's endpoints.Host-declaredguardsoverride for this mixin's endpoints (appended after the host chain).Host-declaredmaxInputoverride for this mixin's endpoints.booleanOpt-in directive: fold this mixin's list-shaped@Restattributes into the host resource's own corresponding chains (not just the mixin's own endpoints).Host-declaredmessagesoverride for this mixin's endpoints.String[]Inheritance-cutoff list for this mixin's sub-context.Class<?>[]Host-declaredparsersoverride for this mixin's endpoints.Class<? extends HttpPartParser>Host-declaredpartParseroverride for this mixin's endpoints.Class<? extends HttpPartSerializer>Host-declaredpartSerializeroverride for this mixin's endpoints.Host-chosen single mount prefix for this mixin's endpoints (re-mount).String[]Host-chosen multi-mount prefixes for this mixin's endpoints (re-mount).String[]Host-declaredproducesoverride for this mixin's endpoints.Class<? extends ResponseProcessor>[]Host-declaredresponseProcessorsoverride for this mixin's endpoints.Host-declaredrestOpArgsoverride for this mixin's endpoints.Host-declaredroleGuardoverride for this mixin's endpoints.Host-declaredrolesDeclaredoverride for this mixin's endpoints.Class<? extends Serializer>[]Host-declaredserializersoverride for this mixin's endpoints.
-
Element Details
-
type
The mixin class to compose into the host resource.Required. Equivalent to a bare entry in
Rest.mixins(), but with the override slots below.- Returns:
- The mixin class.
-
-
-
mergeIntoHost
boolean mergeIntoHostOpt-in directive: fold this mixin's list-shaped@Restattributes into the host resource's own corresponding chains (not just the mixin's own endpoints).By default (
false) a mixin's list-shaped@Restcontributions apply only to the mixin's own endpoints — a host's own@RestOpmethods see only the host's chain (the standardmixininheritance rule "host's chain runs first, then the mixin's appended; host endpoints see only the host's chain"), so a mixin's e.g.responseProcessorsare effectively dropped for host endpoints. Setting this totrueadditionally appends the adopted mixin's own list-shaped@Restattributes to the end of the host's corresponding chains, so the host's own endpoints pick them up too.The folded set is the list-shaped contribution attributes:
serializers,parsers,encoders,converters,guards,responseProcessors,restOpArgs,defaultRequestHeaders,defaultResponseHeaders,defaultRequestAttributes,produces, andconsumes. Replace-shaped attributes (e.g.partSerializer,partParser) and host-only attributes (path/paths/children) are never folded. Same-class de-duplication applies, so a class the host already declares is not added twice.This is strictly opt-in: it has no effect on a bare
Rest.mixins()entry (which cannot set it) or a@Mixinthat leaves itfalse, so existing resources are unaffected. The mixin still mounts its own endpoints as usual — this directive is purely additive to the host chain.Example:
// Auto-wire JspMixin's JspViewRenderer into the host so the host's own @RestOp methods can // return JspView (no need to also list JspViewRenderer in the host's @Rest(responseProcessors)). @Rest (mixinDefs=@Mixin (type=JspMixin.class , mergeIntoHost=true ))public class AppResourceextends RestServlet { ... }- Returns:
- The annotation value.
- Since:
- 10.0.0
- Default:
- false
-
guards
Host-declaredguardsoverride for this mixin's endpoints (appended after the host chain).- Returns:
- The annotation value.
- Default:
- {}
-
roleGuard
Host-declaredroleGuardoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- ""
-
rolesDeclared
Host-declaredrolesDeclaredoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- ""
-
converters
Class<? extends RestConverter>[] convertersHost-declaredconvertersoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- {}
-
encoders
Host-declaredencodersoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- {}
-
serializers
Class<? extends Serializer>[] serializersHost-declaredserializersoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- {}
-
parsers
Host-declaredparsersoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- {}
-
responseProcessors
Class<? extends ResponseProcessor>[] responseProcessorsHost-declaredresponseProcessorsoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- {}
-
restOpArgs
Class<? extends RestOpArg>[] restOpArgsHost-declaredrestOpArgsoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- {}
-
partSerializer
Class<? extends HttpPartSerializer> partSerializerHost-declaredpartSerializeroverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- org.apache.juneau.marshall.httppart.HttpPartSerializer.Void.class
-
partParser
Class<? extends HttpPartParser> partParserHost-declaredpartParseroverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- org.apache.juneau.marshall.httppart.HttpPartParser.Void.class
-
messages
Host-declaredmessagesoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- ""
-
defaultRequestHeaders
Host-declareddefaultRequestHeadersoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- {}
-
defaultResponseHeaders
Host-declareddefaultResponseHeadersoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- {}
-
defaultRequestAttributes
Host-declareddefaultRequestAttributesoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- {}
-
produces
Host-declaredproducesoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- {}
-
consumes
Host-declaredconsumesoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- {}
-
defaultAccept
Host-declareddefaultAcceptoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- ""
-
defaultContentType
Host-declareddefaultContentTypeoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- ""
-
defaultCharset
Host-declareddefaultCharsetoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- ""
-
maxInput
Host-declaredmaxInputoverride for this mixin's endpoints.- Returns:
- The annotation value.
- Default:
- ""
-
path
Host-chosen single mount prefix for this mixin's endpoints (re-mount).- Returns:
- The annotation value.
- Default:
- ""
-
paths
Host-chosen multi-mount prefixes for this mixin's endpoints (re-mount).- Returns:
- The annotation value.
- Default:
- {}
-
noInherit
Inheritance-cutoff list for this mixin's sub-context.Each token names a property whose host→mixin inheritance walk is cut for this mixin (same token set as
Rest.noInherit()). Authoritative over the host override slots above.- Returns:
- The annotation value.
- Default:
- {}
-