-
Notifications
You must be signed in to change notification settings - Fork 0
Description
TL;DR
Improve SPI-related APIs of DatastoreStorageFactory, e.g. expose converterFactory field setter as Builder public API.
The DatastoreStorageFactory provides an SPI API that allows configuring how the InboxStorage instance is created with overring the inboxStorageWith(DatastoreWrapper wrapper, boolean multitenant) method.
But at the same time, the DatastoreStorageFactory itself can only be instantiated with an instance of the respective Builder that has a converterFactory which is essential for the factory. The problem is that this converterFactory field cannot be set via Builder public API and thus the factory cannot be properly instantiated.
The only way to instantiate the factory with a properly built builder right now without reimplementing the factory itself is to use reflection API and set the converterFactory directly, e.g. like this:
private static synchronized void
setConverterFactory(DatastoreStorageFactory.Builder builder, NsConverterFactory factory) {
try {
Field converterFactory = DatastoreStorageFactory.Builder.class
.getDeclaredField("converterFactory");
boolean accessible = converterFactory.isAccessible();
converterFactory.setAccessible(true);
converterFactory.set(builder, factory);
converterFactory.setAccessible(accessible);
} catch (IllegalAccessException | IllegalArgumentException | NoSuchFieldException | SecurityException e) {
throw newIllegalStateException(
e, "Cannot set `converterFactory` for `DatastoreStorageFactory.Builder`."
);
}
}The other desirable change should be a public API that allows configuring the DatastoreMode of the DsInboxStorage instances created with the DatastoreStorageFactory.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status