org.bukkit.plugin
Class SimpleServicesManager

java.lang.Object
  extended by org.bukkit.plugin.SimpleServicesManager
All Implemented Interfaces:
ServicesManager

public class SimpleServicesManager
extends Object
implements ServicesManager

A simple services manager.


Constructor Summary
SimpleServicesManager()
           
 
Method Summary
 Set<Class<?>> getKnownServices()
          Get a list of known services.
<T> RegisteredServiceProvider<T>
getRegistration(Class<T> service)
          Queries for a provider registration.
<T> List<RegisteredServiceProvider<T>>
getRegistrations(Class<T> service)
          Get registrations of providers for a service.
 List<RegisteredServiceProvider<?>> getRegistrations(Plugin plugin)
          Get registrations of providers for a plugin.
<T> boolean
isProvidedFor(Class<T> service)
          Returns whether a provider has been registered for a service.
<T> T
load(Class<T> service)
          Queries for a provider.
<T> void
register(Class<T> service, T provider, Plugin plugin, ServicePriority priority)
          Register a provider of a service.
 void unregister(Class<?> service, Object provider)
          Unregister a particular provider for a particular service.
 void unregister(Object provider)
          Unregister a particular provider.
 void unregisterAll(Plugin plugin)
          Unregister all the providers registered by a particular plugin.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleServicesManager

public SimpleServicesManager()
Method Detail

register

public <T> void register(Class<T> service,
                         T provider,
                         Plugin plugin,
                         ServicePriority priority)
Register a provider of a service.

Specified by:
register in interface ServicesManager
Type Parameters:
T - Provider
Parameters:
service - service class
provider - provider to register
plugin - plugin with the provider
priority - priority of the provider

unregisterAll

public void unregisterAll(Plugin plugin)
Unregister all the providers registered by a particular plugin.

Specified by:
unregisterAll in interface ServicesManager
Parameters:
plugin - The plugin

unregister

public void unregister(Class<?> service,
                       Object provider)
Unregister a particular provider for a particular service.

Specified by:
unregister in interface ServicesManager
Parameters:
service - The service interface
provider - The service provider implementation

unregister

public void unregister(Object provider)
Unregister a particular provider.

Specified by:
unregister in interface ServicesManager
Parameters:
provider - The service provider implementation

load

public <T> T load(Class<T> service)
Queries for a provider. This may return if no provider has been registered for a service. The highest priority provider is returned.

Specified by:
load in interface ServicesManager
Type Parameters:
T - The service interface
Parameters:
service - The service interface
Returns:
provider or null

getRegistration

public <T> RegisteredServiceProvider<T> getRegistration(Class<T> service)
Queries for a provider registration. This may return if no provider has been registered for a service.

Specified by:
getRegistration in interface ServicesManager
Type Parameters:
T - The service interface
Parameters:
service - The service interface
Returns:
provider registration or null

getRegistrations

public List<RegisteredServiceProvider<?>> getRegistrations(Plugin plugin)
Get registrations of providers for a plugin.

Specified by:
getRegistrations in interface ServicesManager
Parameters:
plugin - The plugin
Returns:
provider registration or null

getRegistrations

public <T> List<RegisteredServiceProvider<T>> getRegistrations(Class<T> service)
Get registrations of providers for a service. The returned list is an unmodifiable copy.

Specified by:
getRegistrations in interface ServicesManager
Type Parameters:
T - The service interface
Parameters:
service - The service interface
Returns:
a copy of the list of registrations

getKnownServices

public Set<Class<?>> getKnownServices()
Get a list of known services. A service is known if it has registered providers for it.

Specified by:
getKnownServices in interface ServicesManager
Returns:
a copy of the set of known services

isProvidedFor

public <T> boolean isProvidedFor(Class<T> service)
Returns whether a provider has been registered for a service.

Specified by:
isProvidedFor in interface ServicesManager
Type Parameters:
T - service
Parameters:
service - service to check
Returns:
true if and only if there are registered providers


Copyright © 2013. All Rights Reserved.