Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BraillePlot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Georg Graßnick
BraillePlot
Commits
f200c0bb
Commit
f200c0bb
authored
5 years ago
by
Leonard Kupper
Browse files
Options
Downloads
Plain Diff
Merge origin/master into feat/ConfigurationParser-5
parents
15b33a86
1d4e6b43
No related branches found
No related tags found
1 merge request
!7
Feat/configuration parser 5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
build.gradle
+4
-0
4 additions, 0 deletions
build.gradle
src/main/java/de/tudresden/inf/mci/brailleplot/App.java
+18
-10
18 additions, 10 deletions
src/main/java/de/tudresden/inf/mci/brailleplot/App.java
with
22 additions
and
10 deletions
build.gradle
+
4
−
0
View file @
f200c0bb
...
...
@@ -29,6 +29,10 @@ repositories {
dependencies
{
// Use JUnit test framework
testImplementation
(
'org.junit.jupiter:junit-jupiter:5.4.2'
)
// Logging
compile
group:
'org.slf4j'
,
name:
'slf4j-api'
,
version:
'1.7.26'
compile
group:
'ch.qos.logback'
,
name:
'logback-classic'
,
version:
'1.2.3'
}
test
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/tudresden/inf/mci/brailleplot/App.java
+
18
−
10
View file @
f200c0bb
package
de.tudresden.inf.mci.brailleplot
;
import
de.tudresden.inf.mci.brailleplot.configparser.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.concurrent.ConcurrentLinkedDeque
;
/**
...
...
@@ -27,11 +28,14 @@ public final class App {
private
static
final
int
EXIT_SUCCESS
=
0
;
private
static
final
int
EXIT_ERROR
=
1
;
private
final
Logger
mLogger
;
private
ConcurrentLinkedDeque
<
Runnable
>
mFinalizers
;
private
App
()
{
sInstance
=
this
;
mFinalizers
=
new
ConcurrentLinkedDeque
<>();
mLogger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
}
/**
...
...
@@ -55,7 +59,7 @@ public final class App {
* @param r The task to perform.
*/
public
static
void
registerFinalizer
(
final
Runnable
r
)
{
getInstance
().
mFinalizers
.
add
(
r
);
getInstance
().
mFinalizers
.
add
First
(
r
);
}
private
void
runFinalizers
()
{
...
...
@@ -68,7 +72,7 @@ public final class App {
* Terminate the complete Application in case of an untreatable error.
* @param e The Exception that led to the error.
*/
p
ublic
static
void
terminateWithException
(
final
Exception
e
)
{
p
rivate
void
terminateWithException
(
final
Exception
e
)
{
terminateWithException
(
e
,
""
);
}
...
...
@@ -77,12 +81,12 @@ public final class App {
* @param e The Exception that led to the error.
* @param message An additional message to print to stderr.
*/
p
ublic
static
void
terminateWithException
(
final
Exception
e
,
final
String
message
)
{
p
rivate
void
terminateWithException
(
final
Exception
e
,
final
String
message
)
{
if
(!
message
.
isEmpty
())
{
System
.
err
.
println
(
message
);
mLogger
.
error
(
message
);
}
e
.
printStackTrace
(
);
getInstance
().
runFinalizers
();
mLogger
.
error
(
"Application will now shut down due to an unrecoverable error"
,
e
);
runFinalizers
();
System
.
exit
(
EXIT_ERROR
);
}
...
...
@@ -93,11 +97,15 @@ public final class App {
*/
int
run
(
final
String
[]
args
)
{
// Has to be the first finalizer to be added, so that it is run last
registerFinalizer
(()
->
{
System
.
out
.
println
(
"Application terminated
.
"
);
mLogger
.
info
(
"Application terminated"
);
});
try
{
// Logging example
mLogger
.
info
(
"Application started"
);
// Parse command line parameters
// If requested, print help and exit
...
...
@@ -108,10 +116,10 @@ public final class App {
}
catch
(
final
Exception
e
)
{
terminateWithException
(
e
);
}
finally
{
runFinalizers
();
}
runFinalizers
();
return
EXIT_SUCCESS
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment