Package com.linecorp.armeria.server
Class DecoratingService<T_I extends Request,T_O extends Response,R_I extends Request,R_O extends Response>
- java.lang.Object
-
- com.linecorp.armeria.server.DecoratingService<T_I,T_O,R_I,R_O>
-
- Type Parameters:
T_I
- theRequest
type of theService
being decoratedT_O
- theResponse
type of theService
being decoratedR_I
- theRequest
type of thisService
R_O
- theResponse
type of thisService
- All Implemented Interfaces:
Service<R_I,R_O>
- Direct Known Subclasses:
SimpleDecoratingService
public abstract class DecoratingService<T_I extends Request,T_O extends Response,R_I extends Request,R_O extends Response> extends Object implements Service<R_I,R_O>
AService
that decorates anotherService
. UseSimpleDecoratingService
orService.decorate(DecoratingServiceFunction)
if yourService
has the sameRequest
andResponse
type with theService
being decorated.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DecoratingService(Service<T_I,T_O> delegate)
Creates a new instance that decorates the specifiedService
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Optional<T>
as(Class<T> serviceType)
protected <T extends Service<T_I,T_O>>
Tdelegate()
Returns theService
being decorated.void
serviceAdded(ServiceConfig cfg)
boolean
shouldCachePath(String path, String query, PathMapping pathMapping)
Returns whether the givenpath
andquery
should be cached if the service's result is successful.String
toString()
-
-
-
Method Detail
-
delegate
protected final <T extends Service<T_I,T_O>> T delegate()
Returns theService
being decorated.
-
serviceAdded
public void serviceAdded(ServiceConfig cfg) throws Exception
Description copied from interface:Service
-
as
public final <T> Optional<T> as(Class<T> serviceType)
Description copied from interface:Service
Undecorates thisService
to find theService
which is an instance of the specifiedserviceType
. Use this method instead of an explicit downcast since mostService
s are decorated viaService.decorate(Function)
and thus cannot be downcast. For example:Service s = new MyService().decorate(LoggingService.newDecorator()) .decorate(AuthService.newDecorator()); MyService s1 = s.as(MyService.class); LoggingService s2 = s.as(LoggingService.class); AuthService s3 = s.as(AuthService.class);
-
shouldCachePath
public boolean shouldCachePath(String path, @Nullable String query, PathMapping pathMapping)
Description copied from interface:Service
Returns whether the givenpath
andquery
should be cached if the service's result is successful. By default, exact path mappings with no input query are cached.
-
-