-
-
Notifications
You must be signed in to change notification settings - Fork 199
Expand file tree
/
Copy pathRegistry.java
More file actions
69 lines (63 loc) · 1.99 KB
/
Registry.java
File metadata and controls
69 lines (63 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* Jooby https://jooby.io
* Apache License Version 2.0 https://jooby.io/LICENSE.txt
* Copyright 2014 Edgar Espina
*/
package io.jooby;
import io.jooby.exception.RegistryException;
/**
* Service locator pattern which may be provided by a dependency injection framework.
*
* @since 2.0.0
* @author edgar
* @see ServiceRegistry
*/
public interface Registry {
/**
* Provides an instance of the given type.
*
* @param type Object type.
* @param <T> Object type.
* @return Instance of this type.
* @throws RegistryException If there was a runtime failure while providing an instance.
*/
<T> T require(Class<T> type) throws RegistryException;
/**
* Provides an instance of the given type where name matches it.
*
* @param type Object type.
* @param name Object name.
* @param <T> Object type.
* @return Instance of this type.
* @throws RegistryException If there was a runtime failure while providing an instance.
*/
<T> T require(Class<T> type, String name) throws RegistryException;
/**
* Provides an instance of the given type.
*
* @param type Object type.
* @param <T> Object type.
* @return Instance of this type.
* @throws RegistryException If there was a runtime failure while providing an instance.
*/
<T> T require(Reified<T> type) throws RegistryException;
/**
* Provides an instance of the given type where name matches it.
*
* @param type Object type.
* @param name Object name.
* @param <T> Object type.
* @return Instance of this type.
* @throws RegistryException If there was a runtime failure while providing an instance.
*/
<T> T require(Reified<T> type, String name) throws RegistryException;
/**
* Provides an instance of the given type.
*
* @param key Object key.
* @param <T> Object type.
* @return Instance of this type.
* @throws RegistryException If there was a runtime failure while providing an instance.
*/
<T> T require(ServiceKey<T> key) throws RegistryException;
}