Class ServiceAccess
- java.lang.Object
-
- com._1c.g5.wiring.ServiceAccess
-
public final class ServiceAccess extends Object
Utility methods to get public OSGi services or service suppliers.- See Also:
ServiceSupplier
,AbstractServiceAwareModule
- Restriction:
- This class is not intended to be sub-classed by clients.
- Restriction:
- This class is not intended to be instantiated by clients.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
get(Class<T> serviceType)
Returns an instance of the single known service for the given type.static <T> T
get(Class<T> serviceType, String key, String value)
Returns an instance of the single known service for the given type and the given property.static <T> T
get(Class<T> serviceType, Map<String,?> properties)
Returns an instance of the single known service for the given type and the given properties map.static <T> ServiceSupplier<T>
supplier(Class<T> serviceType, Class<?> source)
Returns supplier of an instance of the single known service for the given type.static <T> ServiceSupplier<T>
supplier(Class<T> serviceType, Class<?> source, String key, Object value)
Returns supplier of an instance of the single known service for the given type and the given property.static <T> ServiceSupplier<T>
supplier(Class<T> serviceType, Class<?> source, Map<String,?> properties)
Returns supplier of an instance of the single known service for the given type and the given properties map.static <T> ServiceSupplier<T>
supplier(Class<T> serviceType, org.eclipse.core.runtime.Plugin bundle)
Returns supplier of an instance of the single known service for the given type.static <T> ServiceSupplier<T>
supplier(Class<T> serviceType, org.eclipse.core.runtime.Plugin bundle, String key, Object value)
Returns supplier of an instance of the single known service for the given type and the given property.static <T> ServiceSupplier<T>
supplier(Class<T> serviceType, org.eclipse.core.runtime.Plugin bundle, Map<String,?> properties)
Returns supplier of an instance of the single known service for the given type and the given properties map.static <T> ServiceSupplier<T>
supplier(Class<T> serviceType, org.osgi.framework.BundleContext context)
Returns supplier of an instance of the single known service for the given type.static <T> ServiceSupplier<T>
supplier(Class<T> serviceType, org.osgi.framework.BundleContext context, String key, Object value)
Returns supplier of an instance of the single known service for the given type and the given property.static <T> ServiceSupplier<T>
supplier(Class<T> serviceType, org.osgi.framework.BundleContext context, Map<String,?> properties)
Returns supplier of an instance of the single known service for the given type and the given properties map.
-
-
-
Method Detail
-
get
public static <T> T get(Class<T> serviceType)
Returns an instance of the single known service for the given type. Clients should always usesupplier(...)
methods instead of this if possible, cause it is faster on multiple service methods usage.Note, that caller should not hold reference to this service, cause it could become stale, and should always get actual service instance.
- Parameters:
serviceType
- the type of service to get, cannot benull
- Returns:
- an instance of the single known service for the given type, never
null
- Throws:
ServiceUnavailableException
- if there is no such service available
-
get
public static <T> T get(Class<T> serviceType, String key, String value)
Returns an instance of the single known service for the given type and the given property. Clients should always usesupplier(...)
methods instead of this if possible, cause it is faster on multiple service methods usage.Note, that caller should not hold reference to this service, cause it could become stale, and should always get actual service instance.
- Parameters:
serviceType
- the type of service to get, cannot benull
key
- the property key, cannot benull
value
- the property value, cannot benull
- Returns:
- an instance of the single known service for the given type, never
null
- Throws:
ServiceUnavailableException
- if there is no such service available
-
get
public static <T> T get(Class<T> serviceType, Map<String,?> properties)
Returns an instance of the single known service for the given type and the given properties map. Clients should always usesupplier(...)
methods instead of this if possible, cause it is faster on multiple service methods usage.Note, that caller should not hold reference to this service, cause it could become stale, and should always get actual service instance.
- Parameters:
serviceType
- the type of service to get, cannot benull
properties
- the service properties map, cannot benull
- Returns:
- an instance of the single known service for the given type, never
null
- Throws:
ServiceUnavailableException
- if there is no such service available or multiple services of theserviceType
andproperties
are registered
-
supplier
public static <T> ServiceSupplier<T> supplier(Class<T> serviceType, Class<?> source)
Returns supplier of an instance of the single known service for the given type.Note, that caller should not hold reference to the supplied service, cause it could become stale, and should always
get
actual service instance.- Parameters:
serviceType
- the type of service to get, cannot benull
source
- the caller source class, typically the class of the caller, cannot benull
- Returns:
- supplier of an instance of the single known service for the given type, never
null
- See Also:
ServiceSupplier
-
supplier
public static <T> ServiceSupplier<T> supplier(Class<T> serviceType, Class<?> source, String key, Object value)
Returns supplier of an instance of the single known service for the given type and the given property.Note, that caller should not hold reference to the supplied service, cause it could become stale, and should always
get
actual service instance.- Parameters:
serviceType
- the type of service to get, cannot benull
source
- the caller source class, typically the class of the caller, cannot benull
key
- the property key, cannot benull
value
- the property value, cannot benull
- Returns:
- supplier of an instance of the single known service for the given type, never
null
- See Also:
ServiceSupplier
-
supplier
public static <T> ServiceSupplier<T> supplier(Class<T> serviceType, Class<?> source, Map<String,?> properties)
Returns supplier of an instance of the single known service for the given type and the given properties map.Note, that caller should not hold reference to the supplied service, cause it could become stale, and should always
get
actual service instance.- Parameters:
serviceType
- the type of service to get, cannot benull
source
- the caller source class, typically the class of the caller, cannot benull
properties
- the service properties map, cannot benull
- Returns:
- supplier of an instance of the single known service for the given type, never
null
- See Also:
ServiceSupplier
-
supplier
public static <T> ServiceSupplier<T> supplier(Class<T> serviceType, org.osgi.framework.BundleContext context)
Returns supplier of an instance of the single known service for the given type.Note, that caller should not hold reference to the supplied service, cause it could become stale, and should always
get
actual service instance.- Parameters:
serviceType
- the type of service to get, cannot benull
context
- the caller bundle context to get service, cannot benull
- Returns:
- supplier of an instance of the single known service for the given type, never
null
- See Also:
ServiceSupplier
-
supplier
public static <T> ServiceSupplier<T> supplier(Class<T> serviceType, org.osgi.framework.BundleContext context, String key, Object value)
Returns supplier of an instance of the single known service for the given type and the given property.Note, that caller should not hold reference to the supplied service, cause it could become stale, and should always
get
actual service instance.- Parameters:
serviceType
- the type of service to get, cannot benull
context
- the caller bundle context to get service, cannot benull
key
- the property key, cannot benull
value
- the property value, cannot benull
- Returns:
- supplier of an instance of the single known service for the given type, never
null
- See Also:
ServiceSupplier
-
supplier
public static <T> ServiceSupplier<T> supplier(Class<T> serviceType, org.osgi.framework.BundleContext context, Map<String,?> properties)
Returns supplier of an instance of the single known service for the given type and the given properties map.Note, that caller should not hold reference to the supplied service, cause it could become stale, and should always
get
actual service instance.- Parameters:
serviceType
- the type of service to get, cannot benull
context
- the caller bundle context to get service, cannot benull
properties
- the service properties map, cannot benull
- Returns:
- supplier of an instance of the single known service for the given type, never
null
- See Also:
ServiceSupplier
-
supplier
public static <T> ServiceSupplier<T> supplier(Class<T> serviceType, org.eclipse.core.runtime.Plugin bundle)
Returns supplier of an instance of the single known service for the given type.Note, that caller should not hold reference to the supplied service, cause it could become stale, and should always
get
actual service instance.- Parameters:
serviceType
- the type of service to get, cannot benull
bundle
- the caller bundle to get service, cannot benull
- Returns:
- supplier of an instance of the single known service for the given type, never
null
- See Also:
ServiceSupplier
-
supplier
public static <T> ServiceSupplier<T> supplier(Class<T> serviceType, org.eclipse.core.runtime.Plugin bundle, String key, Object value)
Returns supplier of an instance of the single known service for the given type and the given property.Note, that caller should not hold reference to the supplied service, cause it could become stale, and should always
get
actual service instance.- Parameters:
serviceType
- the type of service to get, cannot benull
bundle
- the caller bundle to get service, cannot benull
key
- the property key, cannot benull
value
- the property value, cannot benull
- Returns:
- supplier of an instance of the single known service for the given type, never
null
- See Also:
ServiceSupplier
-
supplier
public static <T> ServiceSupplier<T> supplier(Class<T> serviceType, org.eclipse.core.runtime.Plugin bundle, Map<String,?> properties)
Returns supplier of an instance of the single known service for the given type and the given properties map.Note, that caller should not hold reference to the supplied service, cause it could become stale, and should always
get
actual service instance.- Parameters:
serviceType
- the type of service to get, cannot benull
bundle
- the caller bundle to get service, cannot benull
properties
- the service properties map, cannot benull
- Returns:
- supplier of an instance of the single known service for the given type, never
null
- See Also:
ServiceSupplier
-
-