Bootique module (#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
This commit is contained in:
parent
ae827f3122
commit
40b3cc7d2b
11
bootique/config.yml
Normal file
11
bootique/config.yml
Normal file
@ -0,0 +1,11 @@
|
||||
log:
|
||||
level: warn
|
||||
appenders:
|
||||
- type: file
|
||||
logFormat: '%c{20}: %m%n'
|
||||
file: /home/logger.log
|
||||
|
||||
jetty:
|
||||
context: /hello
|
||||
connector:
|
||||
port: 10001
|
50
bootique/dependency-reduced-pom.xml
Normal file
50
bootique/dependency-reduced-pom.xml
Normal file
@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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">
|
||||
<parent>
|
||||
<artifactId>bootique-parent</artifactId>
|
||||
<groupId>io.bootique.parent</groupId>
|
||||
<version>0.12</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung.bootique</groupId>
|
||||
<artifactId>bootique</artifactId>
|
||||
<name>bootique</name>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<url>http://maven.apache.org</url>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.bootique</groupId>
|
||||
<artifactId>bootique-test</artifactId>
|
||||
<version>0.23</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.bootique.bom</groupId>
|
||||
<artifactId>bootique-bom</artifactId>
|
||||
<version>0.23</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<properties>
|
||||
<main.class>com.baeldung.bootique.App</main.class>
|
||||
</properties>
|
||||
</project>
|
||||
|
66
bootique/pom.xml
Normal file
66
bootique/pom.xml
Normal file
@ -0,0 +1,66 @@
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung.bootique</groupId>
|
||||
<artifactId>bootique</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>bootique</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<main.class>com.baeldung.bootique.App</main.class>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>io.bootique.parent</groupId>
|
||||
<artifactId>bootique-parent</artifactId>
|
||||
<version>0.12</version>
|
||||
</parent>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.bootique.bom</groupId>
|
||||
<artifactId>bootique-bom</artifactId>
|
||||
<version>0.23</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.bootique.jersey</groupId>
|
||||
<artifactId>bootique-jersey</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.bootique.logback</groupId>
|
||||
<artifactId>bootique-logback</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.bootique</groupId>
|
||||
<artifactId>bootique-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
42
bootique/src/main/java/com/baeldung/bootique/App.java
Normal file
42
bootique/src/main/java/com/baeldung/bootique/App.java
Normal file
@ -0,0 +1,42 @@
|
||||
package com.baeldung.bootique;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.baeldung.bootique.module.ModuleBinder;
|
||||
import com.baeldung.bootique.router.IndexController;
|
||||
import com.baeldung.bootique.router.SaveController;
|
||||
import com.google.inject.Module;
|
||||
|
||||
import io.bootique.Bootique;
|
||||
import io.bootique.jersey.JerseyModule;
|
||||
import io.bootique.log.BootLogger;
|
||||
|
||||
public class App {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Module module = binder -> JerseyModule.extend(binder).addResource(IndexController.class)
|
||||
.addResource(SaveController.class);
|
||||
Bootique.app(args).module(module).module(ModuleBinder.class).bootLogger(new BootLogger() {
|
||||
@Override
|
||||
public void trace(Supplier<String> arg0) {
|
||||
// ...
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stdout(String arg0) {
|
||||
// ...
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stderr(String arg0, Throwable arg1) {
|
||||
// ...
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stderr(String arg0) {
|
||||
// ...
|
||||
}
|
||||
}).autoLoadModules().exec();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.baeldung.bootique.module;
|
||||
|
||||
import com.baeldung.bootique.service.HelloService;
|
||||
import com.baeldung.bootique.service.impl.HelloServiceImpl;
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Module;
|
||||
|
||||
public class ModuleBinder implements Module {
|
||||
|
||||
@Override
|
||||
public void configure(Binder binder) {
|
||||
binder.bind(HelloService.class).to(HelloServiceImpl.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.baeldung.bootique.module;
|
||||
|
||||
import com.google.inject.Module;
|
||||
|
||||
import io.bootique.BQModuleProvider;
|
||||
|
||||
public class ModuleProvider implements BQModuleProvider {
|
||||
|
||||
@Override
|
||||
public Module module() {
|
||||
return new ModuleBinder();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.baeldung.bootique.router;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
@Path("/")
|
||||
public class IndexController {
|
||||
|
||||
@GET
|
||||
public String index() {
|
||||
return "Hello, baeldung!";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.baeldung.bootique.router;
|
||||
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import com.baeldung.bootique.service.HelloService;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
@Path("/save")
|
||||
public class SaveController {
|
||||
|
||||
@Inject
|
||||
HelloService helloService;
|
||||
|
||||
@POST
|
||||
public String save() {
|
||||
return "Data Saved!";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.baeldung.bootique.service;
|
||||
|
||||
public interface HelloService {
|
||||
|
||||
boolean save();
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.baeldung.bootique.service.impl;
|
||||
|
||||
import com.baeldung.bootique.service.HelloService;
|
||||
|
||||
public class HelloServiceImpl implements HelloService {
|
||||
|
||||
@Override
|
||||
public boolean save() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
com.baeldung.bootique.module.ModuleProvider
|
29
bootique/src/test/java/com/baeldung/bootique/AppTest.java
Normal file
29
bootique/src/test/java/com/baeldung/bootique/AppTest.java
Normal file
@ -0,0 +1,29 @@
|
||||
package com.baeldung.bootique;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.bootique.service.HelloService;
|
||||
|
||||
import io.bootique.BQRuntime;
|
||||
import io.bootique.test.junit.BQDaemonTestFactory;
|
||||
import io.bootique.test.junit.BQTestFactory;
|
||||
|
||||
public class AppTest {
|
||||
|
||||
@Rule
|
||||
public BQTestFactory bqTestFactory = new BQTestFactory();
|
||||
|
||||
@Rule
|
||||
public BQDaemonTestFactory bqDaemonTestFactory = new BQDaemonTestFactory();
|
||||
|
||||
@Test
|
||||
public void givenService_expectBoolen() {
|
||||
BQRuntime runtime = bqTestFactory.app("--server").autoLoadModules().createRuntime();
|
||||
HelloService service = runtime.getInstance(HelloService.class);
|
||||
assertEquals(true, service.save());
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user