Interface ServiceBinder
- All Known Implementing Classes:
ServiceBinderImpl
public static void bind(ServiceBinder
binder)
. This is an adaptation of ideas from Guice.-
Method Summary
Modifier and TypeMethodDescriptionBinds the service interface to a conventionally named service implementation class or defines a service in terms of an implementation class, without a service interface.Binds the service interface to a service implementation class.bind
(Class<T> serviceInterface, ServiceBuilder<T> builder) Alternative implementation that supports a callback to build the service, rather than instantiating a particular class.
-
Method Details
-
bind
Binds the service interface to a conventionally named service implementation class or defines a service in terms of an implementation class, without a service interface.The conventional name for the service implementation class is the same as the name of the service interface with "Impl" appended. For example,
bind(Service.class)
will implicitly attempt to bind toServiceImpl.class
. Usebind(Class, Class)
if the name of the service implementation class does not follow the convention.In case the service is defined through the implementation class, the service will not be proxiable (proxying requires a service interface) and
ServiceDef.getServiceInterface()
will return the implementation class. In this situation, the service will not be proxied; it will be instantiated fully on first reference (ignoring its scope, if any) and will not be decorated.- Type Parameters:
T
-- Parameters:
interfaceClassOrImplementationClass
- service interface class to bind implicitly or implementation class to instantiate as the service- Returns:
- binding options, used to specify additional details about the service
- See Also:
-
bind
Alternative implementation that supports a callback to build the service, rather than instantiating a particular class.- Parameters:
serviceInterface
- interface implemented by the servicebuilder
- constructs the core service implementation- Returns:
- binding options, used to specify additional details about the service
-
bind
Binds the service interface to a service implementation class. The default service name is the unqualified name of the service interface. The default service scope is "singleton", unless the service implementation class includes theScope
annotation.The service implementation class may be omitted (in other words,
bind(Class)
used instead) if the name of the service implementation class is the same as the name of the service interface with "Impl" appended.- Type Parameters:
T
-- Parameters:
serviceInterface
- service interface (used when locating services, and when building proxies)serviceImplementation
- implementation class that implements the service interface- Returns:
- binding options, used to specify additional details about the service
- See Also:
-