Interface Service<I extends Request,​O extends Response>

    • Method Detail

      • serviceAdded

        default void serviceAdded​(ServiceConfig cfg)
                           throws Exception
        Invoked when this Service has been added to a Server with the specified configuration. Please note that this method can be invoked more than once if this Service has been added more than once.
      • as

        default <T> Optional<T> as​(Class<T> type)
        Unwraps this Service into the object of the specified type. Use this method instead of an explicit downcast. For example:
         Service s = new MyService().decorate(LoggingService.newDecorator())
         MyService s1 =;
         LoggingService s2 =;
         AuthService s3 =;
        Specified by:
        as in interface Unwrappable
        type - the type of the object to return
        the object of the specified type if found. Optional.empty() if not found.
        See Also:
      • decorate

        default <R extends Service<?,​?>> R decorate​(Class<R> serviceType)
        Creates a new Service that decorates this Service with a new Service instance of the specified serviceType. The specified Class must have a single-parameter constructor which accepts this Service.
      • shouldCachePath

        default boolean shouldCachePath​(String path,
                                        String query,
                                        Route route)
        Returns whether the given path and query should be cached if the service's result is successful. By default, exact path mappings with no input query are cached.