Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
FIT-Connect-SDK - Java
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
FIT-Connect
FIT-Connect-SDK - Java
Commits
3c3cdc01
Commit
3c3cdc01
authored
2 years ago
by
Martin Vogel
Browse files
Options
Downloads
Patches
Plain Diff
refactor(cmd-runner): load default config from same path as client jar if present
parent
4ce40afb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/README.md
+2
-1
2 additions, 1 deletion
client/README.md
client/src/main/java/dev/fitko/fitconnect/client/cmd/CommandLineRunner.java
+20
-6
20 additions, 6 deletions
...va/dev/fitko/fitconnect/client/cmd/CommandLineRunner.java
with
22 additions
and
7 deletions
client/README.md
+
2
−
1
View file @
3c3cdc01
...
...
@@ -6,7 +6,7 @@ The sdk comes with a commandline client to be able to use the sdk without any co
#### Setup & Build
1.
Build project root wih
``./mvnw clean package``
2.
Go to client/target and find a runnable jar
``client-VERSION.jar``
3.
Provide
[
config yaml
](
../config.yml
)
either via env-var or by loading it programmatically
:
3.
Provide
[
config yaml
](
../config.yml
)
:
1.
set environment variable
``FIT_CONNECT_CONFIG``
:
1.
Linux/MacOS:
``export FIT_CONNECT_CONFIG=path/to/config.yml``
2.
Windows:
``set FIT_CONNECT_CONFIG=C:\Path\To\config.yml``
...
...
@@ -15,6 +15,7 @@ The sdk comes with a commandline client to be able to use the sdk without any co
var
config
=
ApplicationConfigLoader
.
loadConfig
(
"absolute/path/to/config.yml"
);
var
senderClient
=
ClientFactory
.
senderClient
(
config
);
````
3.
put
``config.yml``
in same path as the .jar-file
5.
run client with
``java -jar client-VERSION.jar [COMMAND] [OPTIONS]``
#### SEND Example
...
...
This diff is collapsed.
Click to expand it.
client/src/main/java/dev/fitko/fitconnect/client/cmd/CommandLineRunner.java
+
20
−
6
View file @
3c3cdc01
package
dev.fitko.fitconnect.client.cmd
;
import
dev.fitko.fitconnect.api.config.ApplicationConfig
;
import
dev.fitko.fitconnect.client.SenderClient
;
import
dev.fitko.fitconnect.client.SubscriberClient
;
import
dev.fitko.fitconnect.client.factory.ApplicationConfigLoader
;
import
dev.fitko.fitconnect.client.factory.ClientFactory
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -13,6 +17,7 @@ import java.util.stream.Collectors;
public
final
class
CommandLineRunner
{
private
static
final
String
LOGO
=
"/splash_screen_banner.txt"
;
public
static
final
String
DEFAULT_CONFIG_NAME
=
"config.yml"
;
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
CommandLineRunner
.
class
);
...
...
@@ -24,16 +29,25 @@ public final class CommandLineRunner {
run
(
args
);
}
private
static
void
printSplashScreen
()
{
LOGGER
.
info
(
"{}"
,
getSplashScreenResource
(
LOGO
));
}
private
static
void
run
(
final
String
[]
args
)
throws
IOException
{
final
var
senderClient
=
ClientFactory
.
senderClient
();
final
var
subscriberClient
=
ClientFactory
.
subscriberClient
();
final
ApplicationConfig
config
=
ApplicationConfigLoader
.
loadConfig
(
DEFAULT_CONFIG_NAME
);
final
var
senderClient
=
getSenderClient
(
config
);
final
var
subscriberClient
=
getSubscriberClient
(
config
);
new
CommandLineClient
(
senderClient
,
subscriberClient
).
run
(
args
);
}
private
static
SubscriberClient
.
RequestSubmission
getSubscriberClient
(
final
ApplicationConfig
config
)
{
return
config
!=
null
?
ClientFactory
.
subscriberClient
(
config
)
:
ClientFactory
.
subscriberClient
();
}
private
static
SenderClient
.
Start
getSenderClient
(
final
ApplicationConfig
config
)
{
return
config
!=
null
?
ClientFactory
.
senderClient
(
config
)
:
ClientFactory
.
senderClient
();
}
private
static
void
printSplashScreen
()
{
LOGGER
.
info
(
"{}"
,
getSplashScreenResource
(
LOGO
));
}
private
static
String
getSplashScreenResource
(
final
String
bannerName
)
{
final
InputStream
is
=
CommandLineRunner
.
class
.
getResourceAsStream
(
bannerName
);
return
new
BufferedReader
(
new
InputStreamReader
(
is
)).
lines
().
collect
(
Collectors
.
joining
(
"\n"
));
...
...
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