Class ServiceDescriptor
public class ServiceDescriptor extends Object
This class implements equals(Object)
and hashCode()
on the
service reference, meaning that there should be only one descriptor per
service container and per service.
- See Also:
builder(ServiceReference)
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ServiceDescriptor.Builder
-
Method Summary
Modifier and Type Method Description static ServiceDescriptor.Builder
builder(ServiceReference<?> ref)
Creates a new builder for aServiceDescriptor
.boolean
equals(Object obj)
FactoryMethod
getFactoryMethod()
Gets information about the factory method of the service that will be subject to dependency injection.ServiceReference<?>
getServiceReference()
Gets the service reference targeted by this descriptor.List<SetterMethod>
getSetterMethods()
Gets information about all the setter methods of the service that will be subject to dependency injection.int
hashCode()
boolean
isSingleton()
Gets whether the service is configured as singleton.static ServiceDescriptor
standalone(ServiceReference<?> serviceReference)
Convenience method to create a descriptor for a service that does not have any dependencies.static ServiceDescriptor
standalone(ServiceReference<?> serviceReference, boolean isSingleton)
Convenience method to create a descriptor for a service that does not have any dependencies.String
toString()
-
Method Details
-
getServiceReference
Gets the service reference targeted by this descriptor.- Returns:
- the service reference
-
isSingleton
public boolean isSingleton()Gets whether the service is configured as singleton.- Returns:
- a boolean
-
getFactoryMethod
Gets information about the factory method of the service that will be subject to dependency injection.- Returns:
- the factory method
-
getSetterMethods
Gets information about all the setter methods of the service that will be subject to dependency injection.- Returns:
- the setter methods
-
hashCode
public int hashCode() -
equals
-
toString
-
standalone
public static ServiceDescriptor standalone(ServiceReference<?> serviceReference, boolean isSingleton)Convenience method to create a descriptor for a service that does not have any dependencies. The class must define a public no-arg constructor for it to work. This is equivalent to:ServiceDescriptor.builder(serviceReference).setSingleton(isSingleton).build();
This variant allows to specify whether the service should be a singleton. If you want to define dependencies for the service, see
builder(ServiceReference)
.- Parameters:
serviceReference
- the service referenceisSingleton
- whether the service should be instantiated only once or if a new instance should be created every time it is requested- Returns:
- a new ServiceDescriptor
- Throws:
RdiException
- if the class does not have a public no-arg constructor
-
standalone
Convenience method to create a descriptor for a service that does not have any dependencies. The class must define a public no-arg constructor for it to work. This is equivalent to:ServiceDescriptor.builder(serviceReference).build();
This variant will configure the service as a singleton by default. If you do not want it to be singeton, you may use the overload
standalone(ServiceReference, boolean)
instead. If you want to define dependencies for the service, seebuilder(ServiceReference)
.- Parameters:
serviceReference
- the service reference- Returns:
- a new ServiceDescriptor
- Throws:
RdiException
- if the class does not have a public no-arg constructor
-
builder
Creates a new builder for aServiceDescriptor
.The builder will allow you to define all the dependencies for the service, in factory methods as well as in setters. If your service does not require any dependency, you may prefer to use
standalone(ServiceReference)
andstandalone(ServiceReference, boolean)
.- Parameters:
ref
- the service reference targeted by the descriptor to build- Returns:
- a new builder
-