Sabi
is the class that provies the static methods related to the
global fanctionalities of sabi framework.
This class declares uses
method to register a DaxSrc
object used globally with its name.
And this class also declares setup
, close
,
and startApp
methods.
setup
is the static method to setup all global registered
DaxSrc
objects, and close
is the static method to
free each resource of global DaxSrc
objects.
startApp
is the method that executes setup
and return AutoCloseable
object which executes the close
method in its AutoCloseable.close()
method.
The usages of these static methods is as follows:
public class Application {
static {
Sabi.uses("foo", new FooDaxSrc());
Sabi.uses("bar", new BarDaxSrc());
}
public static void main(String ...args) {
int exitCode = 0;
try {
Sabi.setup();
...
} catch (Exception e) {
exitCode = 1;
} finally {
Sabi.close();
}
System.exit(exitCode);
}
}
Or,
public class Application {
static {
Sabi.uses("foo", new FooDaxSrc());
Sabi.uses("bar", new BarDaxSrc());
}
public static void main(String ...args) {
try (var ac = Sabi.startApp()) {
...
} catch (Exception e) {
System.exit(1);
}
}
}
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
close()
Closes and frees each resource of registered globalDaxSrc
objects.static void
setup()
Makes the globally registeredDaxSrc
object usable.static AutoCloseable
startApp()
Executessetup
method, and returns anAutoCloseable
object of whichclose
method executesclose
method of this class in it.static void
-
Method Details
-
uses
Registers a globalDaxSrc
object with its name to enable to useDaxConn
created by the argumentDaxSrc
in all transactions.If a
DaxSrc
is tried to register with a name already registered, it is ignored and aDaxSrc
registered with the same name first is used. And this method ignore addingDaxSrc
(s) aftersetup
or beginning ofDaxBase.txn(com.github.sttk.sabi.Logic<D>...)
. -
setup
Makes the globally registeredDaxSrc
object usable.This method forbids adding more global
DaxSrc
, and called eachsetup
method of all registeredDaxSrc
objects. If one of globalDaxSrc
objects fails to execute synchronoussetup
, this function stops other setting up and returns anErr
containing the error reason of that failure.If one of global
DaxSrc
objects fails to execute asynchronoussetup
, this function continue to other setting up and returns anErr
containing the error reason of that failure and other errors if any. -
close
public static void close()Closes and frees each resource of registered globalDaxSrc
objects. -
startApp
Executessetup
method, and returns anAutoCloseable
object of whichclose
method executesclose
method of this class in it.- Returns:
- An
AutoCloseable
object. - Throws:
Err
- If one of globalDaxSrc
objects.
-