DataProviderScope is an advanced ownership option.
Use it only when one plugin/software process contains multiple independently managed components.
DataProviderScope chatScope = api.scope("component.chat");You can also use a typed scope object:
OwnerScope chatOwner = OwnerScope.of("component.chat");
DataProviderScope chatScope = api.scope(chatOwner);Scope names must be stable, non-blank, and use safe identifier characters.
Optional<MessagingDataAccess> bus = chatScope.registerDataAccess(
DatabaseType.REDIS_MESSAGING,
"hauntedmc",
MessagingDataAccess.class
);chatScope.unregisterAllDatabases();DataProviderScope is AutoCloseable, so it can also be used with try-with-resources:
try (DataProviderScope tempScope = api.scope("component.temp")) {
tempScope.registerDatabase(DatabaseType.MYSQL, "default");
}Scope cleanup is targeted.
For deterministic full shutdown across all scopes, call:
api.unregisterAllDatabasesForPlugin();