-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathAuditFactory.java
More file actions
31 lines (26 loc) · 1.13 KB
/
AuditFactory.java
File metadata and controls
31 lines (26 loc) · 1.13 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
package com.uid2.shared.audit;
import io.vertx.core.json.JsonObject;
import java.util.HashMap;
import java.util.Map;
/**
* AuditFactory controls the instantiation/creation of AuditMiddleware objects.
* Depending on the needs of the specific implementation, the AuditFactory
* can be implemented to always return the same AuditMiddleware object, create a new
* AuditMiddleware object for every class that calls getAuditMiddleware(Class), or
* exhibit some other behavior.
*/
public class AuditFactory {
private static final Map<JsonObject, IAuditMiddleware> middlewareMap = new HashMap<>();
/**
* Returns an AuditMiddleware object with the designated configuration. If one does
* not already exist, creates a new AuditMiddleware object using the configuration.
*
* @return the designated AuditMiddleware object for the passed class.
*/
public static IAuditMiddleware getAuditMiddleware(JsonObject config){
if(!middlewareMap.containsKey(config)){
middlewareMap.put(config, new AuditMiddlewareImpl(new QLDBAuditWriter(config)));
}
return middlewareMap.get(config);
}
}