public interface ServiceGuiceSupport extends ServiceClientGuiceSupport
Implementors of this interface must invoke bindService(java.lang.Class<T>, java.lang.Class<? extends T>), bindServices(ServiceBinding[]) or bindServiceInfo(ServiceInfo) exactly-once depending on the type of Lagom
service being implemented (1 service, many services, consume-only). These methods setup the
service and may transparently add cross-cutting services like MetricsService (allows
monitoring circuit-breakers from the outside).
| Modifier and Type | Interface and Description |
|---|---|
static class |
ServiceGuiceSupport.ClassServiceBinding<T> |
static class |
ServiceGuiceSupport.InstanceServiceBinding<T> |
static class |
ServiceGuiceSupport.LagomServiceBuilder |
static class |
ServiceGuiceSupport.ServiceBinding<T> |
| Modifier and Type | Method and Description |
|---|---|
default <R extends play.api.routing.Router> |
additionalRouter(Class<R> router)
Helper method to create an
AdditionalRouter instance that can be used to declare
additional Play Routers on a Lagom Service. |
default AdditionalRouter |
additionalRouter(play.api.routing.Router router)
Helper method to create an
AdditionalRouter instance that can be used to declare
additional Play Routers on a Lagom Service. |
default <T extends Service> |
bindService(Class<T> serviceInterface,
Class<? extends T> serviceImplementation)
Binds a Service interface with its implementation.
|
default <T extends Service> |
bindService(Class<T> serviceInterface,
Class<? extends T> serviceImplementation,
AdditionalRouter additionalRouter,
AdditionalRouter... additionalRouters)
Binds a Service interface with its implementation.
|
default <T extends Service> |
bindService(Class<T> serviceInterface,
T service)
Binds a Service interface with an instance that implements it.
|
default <T extends Service> |
bindService(Class<T> serviceInterface,
T service,
AdditionalRouter additionalRouter,
AdditionalRouter... additionalRouters)
Binds a Service interface with an instance that implements it.
|
default void |
bindServiceInfo(ServiceInfo serviceInfo)
Creates a custom
ServiceInfo for this Lagom service. |
default void |
bindServices(ServiceGuiceSupport.ServiceBinding<?>... serviceBindings)
Deprecated.
support for multiple locatable ServiceDescriptors per Lagom service will be
removed. Use
bindService(java.lang.Class<T>, java.lang.Class<? extends T>) instead |
default <T> ServiceGuiceSupport.ServiceBinding<T> |
serviceBinding(Class<T> serviceInterface,
Class<? extends T> serviceImplementation)
Convenience method to create
ServiceGuiceSupport.ServiceBinding when using bindServices(ServiceBinding[]). |
default <T> ServiceGuiceSupport.ServiceBinding<T> |
serviceBinding(Class<T> serviceInterface,
T service)
Convenience method to create
ServiceGuiceSupport.ServiceBinding when using bindServices(ServiceBinding[]). |
bindClient@ApiMayChange default <R extends play.api.routing.Router> AdditionalRouter additionalRouter(Class<R> router)
AdditionalRouter instance that can be used to declare
additional Play Routers on a Lagom Service.
This method should be used when the Router has some dependencies and needs to get
them injected by Lagom's runtime DI infrastructure (Guice).
Typically, this will be a Router generated from a Play routes or a akka-grpc
generated Play Router.
Once you declare a Router, you may need to define its prefix to indicate on which
path it should be available.
bindService(
MyService.class, MyServiceImpl.class,
additionalRouter(HelloWorldRouter.class).withPrefix("/hello"),
);
You don't need to configure a prefix if the Router has it pre-configured. A akka-grpc
generated Play Router, for instance, has its prefix already defined by the gRPC
descriptor and doesn't need to have its prefix reconfigured.
Note that this method won't create a binding and is intended to be used in conjunction with
bindService(Class, Service, AdditionalRouter, AdditionalRouter...)
or bindService(Class, Class, AdditionalRouter,
AdditionalRouter...). Calling this method outside this context will have no effect.
router - an additional Play Router class@ApiMayChange default AdditionalRouter additionalRouter(play.api.routing.Router router)
AdditionalRouter instance that can be used to declare
additional Play Routers on a Lagom Service.
This method should be used when the Router does not have any other dependencies and
therefore can be immediately passed as an instance.
Once you declare a Router, you may need to define its prefix to indicate on which
path it should be available.
bindService(
MyService.class, MyServiceImpl.class,
additionalRouter(new HelloWorldRouter()).withPrefix("/hello"),
);
You don't need to configure a prefix if the Router has it pre-configured.
Note that this method won't create a binding and is intended to be used in conjunction with
bindService(Class, Service, AdditionalRouter, AdditionalRouter...)
or bindService(Class, Class, AdditionalRouter,
AdditionalRouter...). Calling this method outside this context will have no effect.
router - an additional Play Router instancedefault void bindServiceInfo(ServiceInfo serviceInfo)
ServiceInfo for this Lagom service. This method overrides ServiceClientGuiceSupport.bindServiceInfo(ServiceInfo) with custom behavior for consume-only
Lagom services.bindServiceInfo in interface ServiceClientGuiceSupportserviceInfo - the metadata identifying this Lagom Service.default void bindServices(ServiceGuiceSupport.ServiceBinding<?>... serviceBindings)
bindService(java.lang.Class<T>, java.lang.Class<? extends T>) insteadInspects all bindings and creates routes to serve every call described in the bound services.
Builds the ServiceInfo metadata using only the locatable services.
serviceBindings - an arbitrary list of ServiceGuiceSupport.ServiceBindings. Use the convenience method
serviceBinding(Class, Class) to build the ServiceGuiceSupport.ServiceBindings. Despite being a varargs argument, it is required to provide
at least one ServiceGuiceSupport.ServiceBinding as argument.default <T extends Service> void bindService(Class<T> serviceInterface, Class<? extends T> serviceImplementation)
Inspects the service descriptor and creates routes to serve every call described.
Builds the ServiceInfo metadata.
T - type constraint ensuring serviceImplementation implements
serviceInterfaceserviceInterface - the interface class for a ServiceserviceImplementation - the implementation class for the serviceInterfacedefault <T extends Service> void bindService(Class<T> serviceInterface, Class<? extends T> serviceImplementation, AdditionalRouter additionalRouter, AdditionalRouter... additionalRouters)
Inspects the service descriptor and creates routes to serve every call described.
Allows the configuration of additional Play routers.
Builds the ServiceInfo metadata.
T - type constraint ensuring serviceImplementation implements
serviceInterfaceserviceInterface - the interface class for a ServiceserviceImplementation - the implementation class for the serviceInterfaceadditionalRouter - a first AdditionalRouteradditionalRouters - other AdditionalRouter if any (can be omitted)default <T extends Service> void bindService(Class<T> serviceInterface, T service)
Inspects the service descriptor and creates routes to serve every call described.
Builds the ServiceInfo metadata.
T - type constraint ensuring serviceImplementation implements
serviceInterfaceserviceInterface - the interface class for a Serviceservice - an instance of a class implementing serviceInterfacedefault <T extends Service> void bindService(Class<T> serviceInterface, T service, AdditionalRouter additionalRouter, AdditionalRouter... additionalRouters)
Inspects the service descriptor and creates routes to serve every call described.
Allows the configuration of additional Play routers. AdditionalRouter can be
configured using additionalRouter(Class) or additionalRouter(Router).
Builds the ServiceInfo metadata.
T - type constraint ensuring serviceImplementation implements
serviceInterfaceserviceInterface - the interface class for a Serviceservice - an instance of a class implementing serviceInterfaceadditionalRouter - a first AdditionalRouteradditionalRouters - other AdditionalRouter if any (can be omitted)default <T> ServiceGuiceSupport.ServiceBinding<T> serviceBinding(Class<T> serviceInterface, Class<? extends T> serviceImplementation)
ServiceGuiceSupport.ServiceBinding when using bindServices(ServiceBinding[]).ServiceGuiceSupport.ServiceBinding to be used as argument in bindServices(ServiceBinding[]).default <T> ServiceGuiceSupport.ServiceBinding<T> serviceBinding(Class<T> serviceInterface, T service)
ServiceGuiceSupport.ServiceBinding when using bindServices(ServiceBinding[]).T - type constraint ensuring service implements serviceInterface
serviceInterface - the interface class for a serviceservice - an instance of the serviceServiceGuiceSupport.ServiceBinding to be used as argument in bindServices(ServiceBinding[]).