forked from jooby-project/jooby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegistry.java
More file actions
50 lines (45 loc) · 1.42 KB
/
Registry.java
File metadata and controls
50 lines (45 loc) · 1.42 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
/**
* 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;
import javax.annotation.Nonnull;
/**
* 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.
*/
@Nonnull <T> T require(@Nonnull 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.
*/
@Nonnull <T> T require(@Nonnull Class<T> type, @Nonnull 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.
*/
@Nonnull <T> T require(@Nonnull ServiceKey<T> key) throws RegistryException;
}