Class 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().

    • Nested Class Summary

      • Nested classes/interfaces inherited from class jakarta.ws.rs.ext.RuntimeDelegate

        jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate<T extends java.lang.Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String MU_REQUEST_PROPERTY
      The ContainerRequestContext or InterceptorContext property name to use to get the MuRequest for the current JAX-RS request, which can be used in a ContainerRequestFilter, ContainerResponseFilter, ReaderInterceptor or WriterInterceptor.
      static java.lang.String RESOURCE_INFO_PROPERTY
      The ContainerRequestContext or InterceptorContext property name to use to get the ResourceInfo for the current JAX-RS request, which can be used in a ContainerRequestFilter, ContainerResponseFilter, ReaderInterceptor or WriterInterceptor.
      • Fields inherited from class jakarta.ws.rs.ext.RuntimeDelegate

        JAXRS_RUNTIME_DELEGATE_PROPERTY
    • 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
      • Methods inherited from class jakarta.ws.rs.ext.RuntimeDelegate

        getInstance, setInstance
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MU_REQUEST_PROPERTY

        public static final java.lang.String MU_REQUEST_PROPERTY
        The ContainerRequestContext or InterceptorContext property name to use to get the MuRequest for the current JAX-RS request, which can be used in a ContainerRequestFilter, ContainerResponseFilter, ReaderInterceptor or WriterInterceptor.

        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
        The ContainerRequestContext or InterceptorContext property name to use to get the ResourceInfo for the current JAX-RS request, which can be used in a ContainerRequestFilter, ContainerResponseFilter, ReaderInterceptor or WriterInterceptor.

        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 request
        from - The JAX-RS response containing headers
        to - The response to write the headers to
        isHttp1 - The response is an HTTP-1 response
      • createUriBuilder

        public jakarta.ws.rs.core.UriBuilder createUriBuilder()
        Specified by:
        createUriBuilder in class jakarta.ws.rs.ext.RuntimeDelegate
      • createResponseBuilder

        public jakarta.ws.rs.core.Response.ResponseBuilder createResponseBuilder()
        Specified by:
        createResponseBuilder in class jakarta.ws.rs.ext.RuntimeDelegate
      • createVariantListBuilder

        public jakarta.ws.rs.core.Variant.VariantListBuilder createVariantListBuilder()
        Specified by:
        createVariantListBuilder in class jakarta.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 class jakarta.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 class jakarta.ws.rs.ext.RuntimeDelegate
        Throws:
        java.lang.IllegalArgumentException
      • createLinkBuilder

        public jakarta.ws.rs.core.Link.Builder createLinkBuilder()
        Specified by:
        createLinkBuilder in class jakarta.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.