Package arez.persist.runtime
Class ArezPersist
java.lang.Object
arez.persist.runtime.ArezPersist
Provide an interface to register and access stores and access the root scope as well as global configuration settings.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
disposeScope
(Scope scope) Dispose the specified scope.static Scope
findOrCreateScope
(String qualifiedName) Find the scope with the specified name and if it does not exist then create it.static Scope
Find the scope with the specified name.static <A> Converter<A,
?> getConverter
(Class<A> type) Return the converter registered for the specified application type or the identity converter if none are specified.static Scope
Return the root scope under which all other scopes are nested.static Store
Return the store that is registered with the specified name.static boolean
Return true if the in-memory application store should be registered by the framework.static <A> SafeProcedure
registerConverter
(Class<A> type, Converter<A, ?> converter) Register a converter for a type.static SafeProcedure
registerStore
(String name, StorageService service) Register a store with specified name and storage service.static void
releaseScope
(Scope scope) Release the specified scope.static boolean
Return true if apiInvariants will be checked.
-
Method Details
-
shouldCheckApiInvariants
Return true if apiInvariants will be checked.- Returns:
- true if apiInvariants will be checked.
-
isApplicationStoreEnabled
Return true if the in-memory application store should be registered by the framework.- Returns:
- true if the in-memory application store should be registered by the framework.
-
getRootScope
Return the root scope under which all other scopes are nested.- Returns:
- the root scope under which all other scopes are nested.
-
registerStore
@Nonnull public static SafeProcedure registerStore(@Nonnull String name, @Nonnull StorageService service) Register a store with specified name and storage service. It is an error to register multiple stores with the same name.As part of the register operation, the store will attempt to restore state from the storage service. If an error occurs during the restore, then the error will be logged and registration will complete.
- Parameters:
name
- the name of the store.service
- the associated StorageService.- Returns:
- the action to invoke to deregister service.
-
getStore
Return the store that is registered with the specified name. It is an error to invoke this method without registering a store under this name.- Parameters:
name
- the name of the store.- Returns:
- the store.
-
findScope
Find the scope with the specified name. The name can actually consist of name components separated by a "." character. Each name component is nested within the scope identified by the prior name component. i.e. The name "dashboard.finance.entry" will look for the scope named "entry" nested in a scope named "finance" nested in a scope named "dashboard".- Parameters:
qualifiedName
- the qualified scope name.- Returns:
- the scope if it exists.
-
findOrCreateScope
Find the scope with the specified name and if it does not exist then create it. The name can actually consist of name components separated by a "." character. Each name component is nested within the scope identified by the prior name component. i.e. The name "dashboard.finance.entry" will look for the scope named "entry" nested in a scope named "finance" nested in a scope named "dashboard".- Parameters:
qualifiedName
- the qualified scope name.- Returns:
- the scope.
-
disposeScope
Dispose the specified scope. A dispose operation first performs areleaseScope(Scope)
on the scope, then attempts to dispose all nested scopes and finally disposes the specified scope. A disposed scope should no longer be used to store state. It is an error to attempt to dispose the root scope.- Parameters:
scope
- the scope to dispose.
-
releaseScope
Release the specified scope. A release operation removes any state associated with the scope and any nested scope.- Parameters:
scope
- the scope to release.
-
registerConverter
public static <A> SafeProcedure registerConverter(@Nonnull Class<A> type, @Nonnull Converter<A, ?> converter) Register a converter for a type. It is an error to register multiple converters with the same name.- Type Parameters:
A
- the type of the value.- Parameters:
type
- the application type.converter
- the converter.- Returns:
- the action to invoke to deregister converter.
-
getConverter
Return the converter registered for the specified application type or the identity converter if none are specified.- Type Parameters:
A
- the type of the value.- Parameters:
type
- the application type.- Returns:
- the converter if any.
-