Package io.muserver.rest
Class MuRuntimeDelegate
- java.lang.Object
-
- jakarta.ws.rs.ext.RuntimeDelegate
-
- io.muserver.rest.MuRuntimeDelegate
-
public class MuRuntimeDelegate extends jakarta.ws.rs.ext.RuntimeDelegate
The JAX-RS runtime delegate for mu-server.
In most cases this class should not be used, however in cases where you want to test JaxRS classes outside of mu-server you may need to make sure a JAX-RS RuntimeDelegate is set, in which case you can call
ensureSet()
.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
MU_REQUEST_PROPERTY
TheContainerRequestContext
orInterceptorContext
property name to use to get theMuRequest
for the current JAX-RS request, which can be used in aContainerRequestFilter
,ContainerResponseFilter
,ReaderInterceptor
orWriterInterceptor
.static java.lang.String
RESOURCE_INFO_PROPERTY
TheContainerRequestContext
orInterceptorContext
property name to use to get theResourceInfo
for the current JAX-RS request, which can be used in aContainerRequestFilter
,ContainerResponseFilter
,ReaderInterceptor
orWriterInterceptor
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
connectedSinksCount(jakarta.ws.rs.sse.SseBroadcaster broadcaster)
<T> T
createEndpoint(jakarta.ws.rs.core.Application application, java.lang.Class<T> endpointType)
<T> jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate<T>
createHeaderDelegate(java.lang.Class<T> type)
jakarta.ws.rs.core.Link.Builder
createLinkBuilder()
jakarta.ws.rs.core.Response.ResponseBuilder
createResponseBuilder()
static jakarta.ws.rs.sse.Sse
createSseFactory()
Creates a new SSE interface that can create SSE Events and Broadcasters.jakarta.ws.rs.core.UriBuilder
createUriBuilder()
jakarta.ws.rs.core.Variant.VariantListBuilder
createVariantListBuilder()
static jakarta.ws.rs.ext.RuntimeDelegate
ensureSet()
Registers the mu RuntimeDelegate with jax-rs, if it was not already.static void
writeResponseHeaders(java.net.URI requestUri, jakarta.ws.rs.core.Response from, MuResponse to, boolean isHttp1)
Writes headers from a JAX-RS response to a MuResponse
-
-
-
Field Detail
-
MU_REQUEST_PROPERTY
public static final java.lang.String MU_REQUEST_PROPERTY
TheContainerRequestContext
orInterceptorContext
property name to use to get theMuRequest
for the current JAX-RS request, which can be used in aContainerRequestFilter
,ContainerResponseFilter
,ReaderInterceptor
orWriterInterceptor
.Example:
MuRequest muRequest = (MuRequest) requestContext.getProperty(MuRuntimeDelegate.MU_REQUEST_PROPERTY);
- See Also:
- Constant Field Values
-
RESOURCE_INFO_PROPERTY
public static final java.lang.String RESOURCE_INFO_PROPERTY
TheContainerRequestContext
orInterceptorContext
property name to use to get theResourceInfo
for the current JAX-RS request, which can be used in aContainerRequestFilter
,ContainerResponseFilter
,ReaderInterceptor
orWriterInterceptor
.Example:
ResourceInfo resourceInfo = (ResourceInfo) requestContext.getProperty(MuRuntimeDelegate.RESOURCE_INFO_PROPERTY);
- See Also:
- Constant Field Values
-
-
Method Detail
-
ensureSet
public static jakarta.ws.rs.ext.RuntimeDelegate ensureSet()
Registers the mu RuntimeDelegate with jax-rs, if it was not already.- Returns:
- Returns the runtime delegate.
-
connectedSinksCount
public static int connectedSinksCount(jakarta.ws.rs.sse.SseBroadcaster broadcaster)
- Parameters:
broadcaster
- A MuServer SSE broadcaster- Returns:
- the number of SSE clients currently connected to the broadcaster
-
writeResponseHeaders
public static void writeResponseHeaders(java.net.URI requestUri, jakarta.ws.rs.core.Response from, MuResponse to, boolean isHttp1)
Writes headers from a JAX-RS response to a MuResponse- Parameters:
requestUri
- The URI of the current requestfrom
- The JAX-RS response containing headersto
- The response to write the headers toisHttp1
- The response is an HTTP-1 response
-
createUriBuilder
public jakarta.ws.rs.core.UriBuilder createUriBuilder()
- Specified by:
createUriBuilder
in classjakarta.ws.rs.ext.RuntimeDelegate
-
createResponseBuilder
public jakarta.ws.rs.core.Response.ResponseBuilder createResponseBuilder()
- Specified by:
createResponseBuilder
in classjakarta.ws.rs.ext.RuntimeDelegate
-
createVariantListBuilder
public jakarta.ws.rs.core.Variant.VariantListBuilder createVariantListBuilder()
- Specified by:
createVariantListBuilder
in classjakarta.ws.rs.ext.RuntimeDelegate
-
createEndpoint
public <T> T createEndpoint(jakarta.ws.rs.core.Application application, java.lang.Class<T> endpointType) throws java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException
- Specified by:
createEndpoint
in classjakarta.ws.rs.ext.RuntimeDelegate
- Throws:
java.lang.IllegalArgumentException
java.lang.UnsupportedOperationException
-
createHeaderDelegate
public <T> jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate<T> createHeaderDelegate(java.lang.Class<T> type) throws java.lang.IllegalArgumentException
- Specified by:
createHeaderDelegate
in classjakarta.ws.rs.ext.RuntimeDelegate
- Throws:
java.lang.IllegalArgumentException
-
createLinkBuilder
public jakarta.ws.rs.core.Link.Builder createLinkBuilder()
- Specified by:
createLinkBuilder
in classjakarta.ws.rs.ext.RuntimeDelegate
-
createSseFactory
public static jakarta.ws.rs.sse.Sse createSseFactory()
Creates a new SSE interface that can create SSE Events and Broadcasters.
This can be useful if you want to have a singleton broadcaster in your class that you can declare as a final field.
- Returns:
- A broadcaster that can be used to publish SSE events to clients.
-
-