Class JerseySupport

  • All Implemented Interfaces:
    Service

    public class JerseySupport
    extends Object
    implements Service
    The Jersey Support integrates Jersey (JAX-RS RI) into the Web Server.

    To enable Jersey for a given path, do

    
     WebServer.create(Routing.builder()
                             .register("/jersey",
                                       JerseySupport.builder()
                                                    .register(JerseyExampleResource.class)
                                                    .build())
                             .build());
     
    In such case the registered JerseySupport instance gets associated with the Web Server and handles all requests made to /jersey context root.

    Note that due to a blocking IO approach, each request handling is forwarded to a dedicated thread pool which can be configured by one of the JerseySupport constructor.

    • Field Detail

      • REQUEST_SPAN_CONTEXT

        public static final String REQUEST_SPAN_CONTEXT
        The request scoped span context qualifier that can be injected into a Jersey resource.
        
         @Inject@Named(JerseySupport.REQUEST_SPAN_CONTEXT)
          private SpanContext spanContext;
         
        See Also:
        Constant Field Values
    • Method Detail

      • close

        public void close()
        Close this integration with Jersey. Once closed, this instance is no longer usable.
      • create

        public static JerseySupport create​(Application application)
        Creates JerseySupport based on the provided JAX-RS Application.
         WebServer.create(Routing.builder()
                                 .register("/jersey",
                                           JerseySupport.create(new ResourceConfig(JerseyExampleResource.class)))
                                 .build());
         
        Parameters:
        application - the JAX-RS application to create this instance based on
        Returns:
        the Jersey Support instance
        See Also:
        builder(Application)
      • builder

        public static JerseySupport.Builder builder()
        Creates JerseySupport builder based on default empty ResourceConfig.

        Every component must be registered on this builder by calling any of register methods. Properties can be set by the builder method JerseySupport.Builder.property(String, Object).

        Build WebServer:

         WebServer.create(Routing.builder()
                                 .register("/jersey",
                                           JerseySupport.builder()
                                                        .register(JerseyExampleResource.class)
                                                        .build())
                                 .build());
         
        Returns:
        this
        See Also:
        builder(Application)
      • builder

        public static JerseySupport.Builder builder​(Application application)
        Creates JerseySupport builder based on a passed application.

        The application might be extended by calling any of register methods. Properties can be set by the application, the builder method JerseySupport.Builder.property(String, Object).

        Build WebServer:

         WebServer.create(Routing.builder()
                                 .register("/jersey",
                                           JerseySupport.builder()
                                                        .register(JerseyExampleResource.class)
                                                        .build())
                                 .build());
         
        Parameters:
        application - a base application
        Returns:
        this