Skip to content

Commit 40b3cc7

Browse files
AbhinabKanrarpivovarit
authored andcommitted
Bootique module (eugenp#2376)
* moving jmh into libraries module * refactoring jmh * Update pom.xml * manual algorightm * with BM result * fix for space issue * Fixed indentation * change as per suggestion * vavr either * adding unit test and othe rutilities * adding concurrent module * concurrent package description * concurrent package description * Update EitherUnitTest.java * introducing lambda expression * jooby project * jooby project * reducing employee bean content * bootique module * bootique * bootique
1 parent ae827f3 commit 40b3cc7

File tree

12 files changed

+281
-0
lines changed

12 files changed

+281
-0
lines changed

bootique/config.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
log:
2+
level: warn
3+
appenders:
4+
- type: file
5+
logFormat: '%c{20}: %m%n'
6+
file: /home/logger.log
7+
8+
jetty:
9+
context: /hello
10+
connector:
11+
port: 10001
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<parent>
4+
<artifactId>bootique-parent</artifactId>
5+
<groupId>io.bootique.parent</groupId>
6+
<version>0.12</version>
7+
</parent>
8+
<modelVersion>4.0.0</modelVersion>
9+
<groupId>com.baeldung.bootique</groupId>
10+
<artifactId>bootique</artifactId>
11+
<name>bootique</name>
12+
<version>1.0-SNAPSHOT</version>
13+
<url>http://maven.apache.org</url>
14+
<build>
15+
<plugins>
16+
<plugin>
17+
<artifactId>maven-shade-plugin</artifactId>
18+
</plugin>
19+
</plugins>
20+
</build>
21+
<dependencies>
22+
<dependency>
23+
<groupId>io.bootique</groupId>
24+
<artifactId>bootique-test</artifactId>
25+
<version>0.23</version>
26+
<scope>test</scope>
27+
</dependency>
28+
<dependency>
29+
<groupId>junit</groupId>
30+
<artifactId>junit</artifactId>
31+
<version>3.8.1</version>
32+
<scope>test</scope>
33+
</dependency>
34+
</dependencies>
35+
<dependencyManagement>
36+
<dependencies>
37+
<dependency>
38+
<groupId>io.bootique.bom</groupId>
39+
<artifactId>bootique-bom</artifactId>
40+
<version>0.23</version>
41+
<type>pom</type>
42+
<scope>import</scope>
43+
</dependency>
44+
</dependencies>
45+
</dependencyManagement>
46+
<properties>
47+
<main.class>com.baeldung.bootique.App</main.class>
48+
</properties>
49+
</project>
50+

bootique/pom.xml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.baeldung.bootique</groupId>
5+
<artifactId>bootique</artifactId>
6+
<packaging>jar</packaging>
7+
<version>1.0-SNAPSHOT</version>
8+
<name>bootique</name>
9+
<url>http://maven.apache.org</url>
10+
11+
<properties>
12+
<main.class>com.baeldung.bootique.App</main.class>
13+
</properties>
14+
15+
<parent>
16+
<groupId>io.bootique.parent</groupId>
17+
<artifactId>bootique-parent</artifactId>
18+
<version>0.12</version>
19+
</parent>
20+
21+
<dependencyManagement>
22+
<dependencies>
23+
<dependency>
24+
<groupId>io.bootique.bom</groupId>
25+
<artifactId>bootique-bom</artifactId>
26+
<version>0.23</version>
27+
<type>pom</type>
28+
<scope>import</scope>
29+
</dependency>
30+
</dependencies>
31+
</dependencyManagement>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>io.bootique.jersey</groupId>
36+
<artifactId>bootique-jersey</artifactId>
37+
<scope>compile</scope>
38+
</dependency>
39+
<dependency>
40+
<groupId>io.bootique.logback</groupId>
41+
<artifactId>bootique-logback</artifactId>
42+
<scope>compile</scope>
43+
</dependency>
44+
<dependency>
45+
<groupId>io.bootique</groupId>
46+
<artifactId>bootique-test</artifactId>
47+
<scope>test</scope>
48+
</dependency>
49+
<dependency>
50+
<groupId>junit</groupId>
51+
<artifactId>junit</artifactId>
52+
<version>4.12</version>
53+
<scope>test</scope>
54+
</dependency>
55+
</dependencies>
56+
57+
<build>
58+
<plugins>
59+
<plugin>
60+
<groupId>org.apache.maven.plugins</groupId>
61+
<artifactId>maven-shade-plugin</artifactId>
62+
</plugin>
63+
</plugins>
64+
</build>
65+
66+
</project>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.baeldung.bootique;
2+
3+
import java.util.function.Supplier;
4+
5+
import com.baeldung.bootique.module.ModuleBinder;
6+
import com.baeldung.bootique.router.IndexController;
7+
import com.baeldung.bootique.router.SaveController;
8+
import com.google.inject.Module;
9+
10+
import io.bootique.Bootique;
11+
import io.bootique.jersey.JerseyModule;
12+
import io.bootique.log.BootLogger;
13+
14+
public class App {
15+
16+
public static void main(String[] args) {
17+
Module module = binder -> JerseyModule.extend(binder).addResource(IndexController.class)
18+
.addResource(SaveController.class);
19+
Bootique.app(args).module(module).module(ModuleBinder.class).bootLogger(new BootLogger() {
20+
@Override
21+
public void trace(Supplier<String> arg0) {
22+
// ...
23+
}
24+
25+
@Override
26+
public void stdout(String arg0) {
27+
// ...
28+
}
29+
30+
@Override
31+
public void stderr(String arg0, Throwable arg1) {
32+
// ...
33+
}
34+
35+
@Override
36+
public void stderr(String arg0) {
37+
// ...
38+
}
39+
}).autoLoadModules().exec();
40+
}
41+
42+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.baeldung.bootique.module;
2+
3+
import com.baeldung.bootique.service.HelloService;
4+
import com.baeldung.bootique.service.impl.HelloServiceImpl;
5+
import com.google.inject.Binder;
6+
import com.google.inject.Module;
7+
8+
public class ModuleBinder implements Module {
9+
10+
@Override
11+
public void configure(Binder binder) {
12+
binder.bind(HelloService.class).to(HelloServiceImpl.class);
13+
}
14+
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.baeldung.bootique.module;
2+
3+
import com.google.inject.Module;
4+
5+
import io.bootique.BQModuleProvider;
6+
7+
public class ModuleProvider implements BQModuleProvider {
8+
9+
@Override
10+
public Module module() {
11+
return new ModuleBinder();
12+
}
13+
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.baeldung.bootique.router;
2+
3+
import javax.ws.rs.GET;
4+
import javax.ws.rs.Path;
5+
6+
@Path("/")
7+
public class IndexController {
8+
9+
@GET
10+
public String index() {
11+
return "Hello, baeldung!";
12+
}
13+
14+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.baeldung.bootique.router;
2+
3+
import javax.ws.rs.POST;
4+
import javax.ws.rs.Path;
5+
6+
import com.baeldung.bootique.service.HelloService;
7+
import com.google.inject.Inject;
8+
9+
@Path("/save")
10+
public class SaveController {
11+
12+
@Inject
13+
HelloService helloService;
14+
15+
@POST
16+
public String save() {
17+
return "Data Saved!";
18+
}
19+
20+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.baeldung.bootique.service;
2+
3+
public interface HelloService {
4+
5+
boolean save();
6+
7+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.baeldung.bootique.service.impl;
2+
3+
import com.baeldung.bootique.service.HelloService;
4+
5+
public class HelloServiceImpl implements HelloService {
6+
7+
@Override
8+
public boolean save() {
9+
return true;
10+
}
11+
12+
}

0 commit comments

Comments
 (0)