接口 ServicesManager
- 所有已知实现类:
SimpleServicesManager
-
方法概要
修饰符和类型方法说明@NotNull Collection<Class<?>>获取已知服务列表.getRegistration(@NotNull Class<T> service) 查询提供者注册信息.getRegistrations(@NotNull Class<T> service) 获取服务的提供者注册信息.getRegistrations(@NotNull Plugin plugin) 获取插件的提供者注册信息.<T> booleanisProvidedFor(@NotNull Class<T> service) 返回是否已为服务注册了提供者.<T> T查询提供者.<T> voidregister(@NotNull Class<T> service, T provider, @NotNull Plugin plugin, @NotNull ServicePriority priority) 注册一个服务的提供者.voidunregister(@NotNull Class<?> service, @NotNull Object provider) 注销特定服务的特定提供者.voidunregister(@NotNull Object provider) 注销特定提供者.voidunregisterAll(@NotNull Plugin plugin) 注销特定插件注册的所有提供者.
-
方法详细资料
-
register
<T> void register(@NotNull @NotNull Class<T> service, @NotNull T provider, @NotNull @NotNull Plugin plugin, @NotNull @NotNull ServicePriority priority) 注册一个服务的提供者.原文: Register a provider of a service.
- 类型参数:
T- 提供者类型- 参数:
service- 服务类provider- 要注册的提供者plugin- 拥有该提供者的插件priority- 提供者的优先级
-
unregisterAll
注销特定插件注册的所有提供者.原文: Unregister all the providers registered by a particular plugin.
- 参数:
plugin- 要注销的插件
-
unregister
注销特定服务的特定提供者.原文: Unregister a particular provider for a particular service.
- 参数:
service- 服务接口provider- 服务提供者实现
-
unregister
注销特定提供者.原文: Unregister a particular provider.
- 参数:
provider- 服务提供者实现
-
load
查询提供者. 如果没有为服务注册提供者, 可能返回 null. 返回优先级最高的提供者.原文: Queries for a provider. This may return null if no provider has been registered for a service. The highest priority provider is returned.
- 类型参数:
T- 服务接口类型- 参数:
service- 服务接口- 返回:
- 提供者或 null
-
getRegistration
@Nullable <T> @Nullable RegisteredServiceProvider<T> getRegistration(@NotNull @NotNull Class<T> service) 查询提供者注册信息. 如果没有为服务注册提供者, 可能返回 null.原文: Queries for a provider registration. This may return null if no provider has been registered for a service.
- 类型参数:
T- 服务接口类型- 参数:
service- 服务接口- 返回:
- 提供者注册信息或 null
-
getRegistrations
@NotNull @NotNull List<RegisteredServiceProvider<?>> getRegistrations(@NotNull @NotNull Plugin plugin) 获取插件的提供者注册信息.原文: Get registrations of providers for a plugin.
- 参数:
plugin- 插件- 返回:
- 提供者注册信息
-
getRegistrations
@NotNull <T> @NotNull Collection<RegisteredServiceProvider<T>> getRegistrations(@NotNull @NotNull Class<T> service) 获取服务的提供者注册信息. 返回的列表是不可修改的.原文: Get registrations of providers for a service. The returned list is unmodifiable.
- 类型参数:
T- 服务接口类型- 参数:
service- 服务接口- 返回:
- 注册信息列表
-
getKnownServices
获取已知服务列表. 如果服务有已注册的提供者, 则该服务是已知的.原文: Get a list of known services. A service is known if it has registered providers for it.
- 返回:
- 已知服务列表
-
isProvidedFor
返回是否已为服务注册了提供者. 不要先检查此方法然后再调用load(service), 因为那将是非线程安全的情况.原文: Returns whether a provider has been registered for a service. Do not check this first only to call load(service) later, as that would be a non-thread safe situation.
- 类型参数:
T- 服务类型- 参数:
service- 要检查的服务- 返回:
- 是否有已注册的提供者
-