Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
ServicesManager.java
1 package org.bukkit.plugin;
2 
3 import java.util.Collection;
4 import java.util.List;
5 
6 /**
7  * Manages services and service providers. Services are an interface
8  * specifying a list of methods that a provider must implement. Providers are
9  * implementations of these services. A provider can be queried from the
10  * services manager in order to use a service (if one is available). If
11  * multiple plugins register a service, then the service with the highest
12  * priority takes precedence.
13  */
14 public interface ServicesManager {
15 
16  /**
17  * Register a provider of a service.
18  *
19  * @param <T> Provider
20  * @param service service class
21  * @param provider provider to register
22  * @param plugin plugin with the provider
23  * @param priority priority of the provider
24  */
25  public <T> void register(Class<T> service, T provider, Plugin plugin, ServicePriority priority);
26 
27  /**
28  * Unregister all the providers registered by a particular plugin.
29  *
30  * @param plugin The plugin
31  */
32  public void unregisterAll(Plugin plugin);
33 
34  /**
35  * Unregister a particular provider for a particular service.
36  *
37  * @param service The service interface
38  * @param provider The service provider implementation
39  */
40  public void unregister(Class<?> service, Object provider);
41 
42  /**
43  * Unregister a particular provider.
44  *
45  * @param provider The service provider implementation
46  */
47  public void unregister(Object provider);
48 
49  /**
50  * Queries for a provider. This may return if no provider has been
51  * registered for a service. The highest priority provider is returned.
52  *
53  * @param <T> The service interface
54  * @param service The service interface
55  * @return provider or null
56  */
57  public <T> T load(Class<T> service);
58 
59  /**
60  * Queries for a provider registration. This may return if no provider
61  * has been registered for a service.
62  *
63  * @param <T> The service interface
64  * @param service The service interface
65  * @return provider registration or null
66  */
67  public <T> RegisteredServiceProvider<T> getRegistration(Class<T> service);
68 
69  /**
70  * Get registrations of providers for a plugin.
71  *
72  * @param plugin The plugin
73  * @return provider registration or null
74  */
75  public List<RegisteredServiceProvider<?>> getRegistrations(Plugin plugin);
76 
77  /**
78  * Get registrations of providers for a service. The returned list is
79  * unmodifiable.
80  *
81  * @param <T> The service interface
82  * @param service The service interface
83  * @return list of registrations
84  */
85  public <T> Collection<RegisteredServiceProvider<T>> getRegistrations(Class<T> service);
86 
87  /**
88  * Get a list of known services. A service is known if it has registered
89  * providers for it.
90  *
91  * @return list of known services
92  */
93  public Collection<Class<?>> getKnownServices();
94 
95  /**
96  * Returns whether a provider has been registered for a service. Do not
97  * check this first only to call <code>load(service)</code> later, as that
98  * would be a non-thread safe situation.
99  *
100  * @param <T> service
101  * @param service service to check
102  * @return whether there has been a registered provider
103  */
104  public <T> boolean isProvidedFor(Class<T> service);
105 
106 }
public< T > RegisteredServiceProvider< T > getRegistration(Class< T > service)
public< T > T load(Class< T > service)
Collection< Class<?> > getKnownServices()
List< RegisteredServiceProvider<?> > getRegistrations(Plugin plugin)
void unregisterAll(Plugin plugin)
void unregister(Class<?> service, Object provider)
public< T > boolean isProvidedFor(Class< T > service)