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