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.RuntimeDelegateThe 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.StringMU_REQUEST_PROPERTYTheContainerRequestContextorInterceptorContextproperty name to use to get theMuRequestfor the current JAX-RS request, which can be used in aContainerRequestFilter,ContainerResponseFilter,ReaderInterceptororWriterInterceptor.static java.lang.StringRESOURCE_INFO_PROPERTYTheContainerRequestContextorInterceptorContextproperty name to use to get theResourceInfofor the current JAX-RS request, which can be used in aContainerRequestFilter,ContainerResponseFilter,ReaderInterceptororWriterInterceptor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intconnectedSinksCount(jakarta.ws.rs.sse.SseBroadcaster broadcaster)<T> TcreateEndpoint(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.BuildercreateLinkBuilder()jakarta.ws.rs.core.Response.ResponseBuildercreateResponseBuilder()static jakarta.ws.rs.sse.SsecreateSseFactory()Creates a new SSE interface that can create SSE Events and Broadcasters.jakarta.ws.rs.core.UriBuildercreateUriBuilder()jakarta.ws.rs.core.Variant.VariantListBuildercreateVariantListBuilder()static jakarta.ws.rs.ext.RuntimeDelegateensureSet()Registers the mu RuntimeDelegate with jax-rs, if it was not already.static voidwriteResponseHeaders(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
TheContainerRequestContextorInterceptorContextproperty name to use to get theMuRequestfor the current JAX-RS request, which can be used in aContainerRequestFilter,ContainerResponseFilter,ReaderInterceptororWriterInterceptor.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
TheContainerRequestContextorInterceptorContextproperty name to use to get theResourceInfofor the current JAX-RS request, which can be used in aContainerRequestFilter,ContainerResponseFilter,ReaderInterceptororWriterInterceptor.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:
createUriBuilderin classjakarta.ws.rs.ext.RuntimeDelegate
-
createResponseBuilder
public jakarta.ws.rs.core.Response.ResponseBuilder createResponseBuilder()
- Specified by:
createResponseBuilderin classjakarta.ws.rs.ext.RuntimeDelegate
-
createVariantListBuilder
public jakarta.ws.rs.core.Variant.VariantListBuilder createVariantListBuilder()
- Specified by:
createVariantListBuilderin 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:
createEndpointin classjakarta.ws.rs.ext.RuntimeDelegate- Throws:
java.lang.IllegalArgumentExceptionjava.lang.UnsupportedOperationException
-
createHeaderDelegate
public <T> jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate<T> createHeaderDelegate(java.lang.Class<T> type) throws java.lang.IllegalArgumentException- Specified by:
createHeaderDelegatein classjakarta.ws.rs.ext.RuntimeDelegate- Throws:
java.lang.IllegalArgumentException
-
createLinkBuilder
public jakarta.ws.rs.core.Link.Builder createLinkBuilder()
- Specified by:
createLinkBuilderin 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.
-
-