Skip to content

Commit 3fea652

Browse files
committed
add possibility to associate data to an application
1 parent 90ff0cd commit 3fea652

File tree

1 file changed

+11
-0
lines changed
  • net.lecousin.core/src/main/java/net/lecousin/framework/application

1 file changed

+11
-0
lines changed

net.lecousin.core/src/main/java/net/lecousin/framework/application/Application.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ private Application(
9292
private String[] languageTag;
9393
private LoggerFactory loggerFactory;
9494
private Map<Class<?>, Object> instances = new HashMap<>();
95+
private Map<String, Object> data = new HashMap<>();
9596
private ArrayList<Closeable> toCloseSync = new ArrayList<>();
9697
private ArrayList<AsyncCloseable<?>> toCloseAsync = new ArrayList<>();
9798
private boolean stopping = false;
@@ -239,6 +240,16 @@ public <T> void setInstance(Class<T> clazz, T instance) {
239240
instances.put(clazz, instance);
240241
}
241242

243+
/** Get a data associated with this application. */
244+
public Object getData(String name) {
245+
return data.get(name);
246+
}
247+
248+
/** Set a data associated with this application and return previously associated data with this name. */
249+
public Object setData(String name, Object value) {
250+
return data.put(name, value);
251+
}
252+
242253
/** Method to call at the beginning of the application, typically in the main method. */
243254
public static ISynchronizationPoint<Exception> start(
244255
Artifact artifact,

0 commit comments

Comments
 (0)