Skip to content

Commit 244a678

Browse files
AbhinabKanrarpivovarit
authored andcommitted
jooby project (eugenp#2330)
* 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
1 parent 5c1bf55 commit 244a678

12 files changed

Lines changed: 349 additions & 0 deletions

File tree

‎core-java/src/main/java/com/baeldung/concurrent/cyclicbarrier/CyclicBarrierExample.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ public void start() {
2121
}
2222
}
2323
}
24+

‎jooby/conf/application.conf‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#application.secret = 2o128940921eo298e21
2+
#db = /url/to/the/datastore

‎jooby/conf/logback.xml‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration scan="true" scanPeriod="15 seconds" debug="false">
3+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4+
<encoder>
5+
<pattern>[%d{ISO8601}]-[%thread] %-5level %logger - %msg%n</pattern>
6+
</encoder>
7+
</appender>
8+
9+
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
10+
<file>log/jooby.log</file>
11+
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
12+
<fileNamePattern>log/jooby.%d{yyyy-MM-dd}.log</fileNamePattern>
13+
<totalSizeCap>1mb</totalSizeCap>
14+
<maxHistory>7</maxHistory>
15+
</rollingPolicy>
16+
17+
<encoder>
18+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
19+
</encoder>
20+
</appender>
21+
22+
<appender name="ACCESS" class="ch.qos.logback.core.rolling.RollingFileAppender">
23+
<file>log/access.log</file>
24+
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
25+
<fileNamePattern>log/access.%d{yyyy-MM-dd}.log</fileNamePattern>
26+
<totalSizeCap>1mb</totalSizeCap>
27+
<maxHistory>7</maxHistory>
28+
</rollingPolicy>
29+
30+
<encoder>
31+
<pattern>%msg%n</pattern>
32+
</encoder>
33+
</appender>
34+
35+
<logger name="org.jooby.RequestLogger" additivity="false">
36+
<appender-ref ref="ACCESS" />
37+
</logger>
38+
39+
<root level="INFO">
40+
<appender-ref ref="STDOUT" />
41+
</root>
42+
</configuration>

‎jooby/pom.xml‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<artifactId>jooby</artifactId>
6+
<groupId>com.baeldung.jooby</groupId>
7+
<version>1.0</version>
8+
<name>jooby</name>
9+
10+
<parent>
11+
<groupId>org.jooby</groupId>
12+
<artifactId>modules</artifactId>
13+
<version>1.1.3</version>
14+
</parent>
15+
16+
<properties>
17+
<jooby.version>1.1.3</jooby.version>
18+
<application.class>com.baeldung.jooby.App</application.class>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.jooby</groupId>
24+
<artifactId>jooby-netty</artifactId>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.jooby</groupId>
28+
<artifactId>jooby-jedis</artifactId>
29+
<version>1.1.3</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>ch.qos.logback</groupId>
33+
<artifactId>logback-classic</artifactId>
34+
</dependency>
35+
<dependency>
36+
<groupId>junit</groupId>
37+
<artifactId>junit</artifactId>
38+
<scope>test</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>io.rest-assured</groupId>
42+
<artifactId>rest-assured</artifactId>
43+
<scope>test</scope>
44+
</dependency>
45+
</dependencies>
46+
47+
<build>
48+
<plugins>
49+
<plugin>
50+
<groupId>org.apache.maven.plugins</groupId>
51+
<artifactId>maven-shade-plugin</artifactId>
52+
</plugin>
53+
</plugins>
54+
</build>
55+
56+
</project>

‎jooby/public/form.html‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Insert title here</title>
6+
</head>
7+
<body>
8+
<form enctype="application/x-www-form-urlencoded" action="/submitForm" method="post">
9+
<input name="id" />
10+
<input name="name" />
11+
<input name="email" />
12+
<input name="phone" />
13+
<input name="address" />
14+
<input type="submit" value="Submit"/>
15+
</form>
16+
</body>
17+
</html>

‎jooby/public/welcome.html‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Insert title here</title>
6+
</head>
7+
<body>
8+
i m welcomed
9+
</body>
10+
</html>

‎jooby/src/etc/stork.yml‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Name of application (make sure it has no spaces)
2+
name: "${project.artifactId}"
3+
4+
# Display name of application (can have spaces)
5+
display_name: "${project.name}"
6+
7+
# Type of launcher (CONSOLE or DAEMON)
8+
type: DAEMON
9+
10+
# Java class to run
11+
main_class: "${application.class}"
12+
13+
domain: "${project.groupId}"
14+
15+
short_description: "${project.artifactId}"
16+
17+
# Platform launchers to generate (WINDOWS, LINUX, MAC_OSX)
18+
# Linux launcher is suitable for Bourne shells (e.g. Linux/BSD)
19+
platforms: [ LINUX ]
20+
21+
# Working directory for app
22+
# RETAIN will not change the working directory
23+
# APP_HOME will change the working directory to the home of the app
24+
# (where it was intalled) before running the main class
25+
working_dir_mode: RETAIN
26+
27+
# Minimum version of java required (system will be searched for acceptable jvm)
28+
min_java_version: "1.8"
29+
30+
# Min/max fixed memory (measured in MB)
31+
min_java_memory: 512
32+
max_java_memory: 512
33+
34+
# Min/max memory by percentage of system
35+
#min_java_memory_pct: 10
36+
#max_java_memory_pct: 20
37+
38+
# Try to create a symbolic link to java executable in <app_home>/run with
39+
# the name of "<app_name>-java" so that commands like "ps" will make it
40+
# easier to find your app
41+
symlink_java: true
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package com.baeldung.jooby;
2+
3+
import org.jooby.Jooby;
4+
import org.jooby.Mutant;
5+
import org.jooby.Session;
6+
import org.jooby.jedis.Redis;
7+
import org.jooby.jedis.RedisSessionStore;
8+
9+
import com.baeldung.jooby.bean.Employee;
10+
11+
public class App extends Jooby {
12+
13+
{
14+
port(8080);
15+
securePort(8443);
16+
}
17+
18+
{
19+
get("/", () -> "Hello World!");
20+
}
21+
22+
{
23+
get("/user/{id}", req -> "Hello user : " + req.param("id").value());
24+
get("/user/:id", req -> "Hello user: " + req.param("id").value());
25+
get("/uid:{id}", req -> "Hello User with id : uid" + req.param("id").value());
26+
}
27+
28+
{
29+
onStart(() -> {
30+
System.out.println("starting app");
31+
});
32+
33+
onStop(() -> {
34+
System.out.println("stopping app");
35+
});
36+
37+
onStarted(() -> {
38+
System.out.println("app started");
39+
});
40+
}
41+
42+
{
43+
get("/login", () -> "Hello from Baeldung");
44+
}
45+
46+
{
47+
post("/save", req -> {
48+
Mutant token = req.param("token");
49+
return token.intValue();
50+
});
51+
}
52+
53+
{
54+
{
55+
assets("/employee", "form.html");
56+
}
57+
58+
post("/submitForm", req -> {
59+
Employee employee = req.params(Employee.class);
60+
// TODO
61+
return "empoyee data saved successfullly";
62+
});
63+
}
64+
65+
{
66+
get("/filter", (req, resp, chain) -> {
67+
// TODO
68+
// resp.send(...);
69+
chain.next(req, resp);
70+
});
71+
get("/filter", (req, resp) -> {
72+
resp.send("filter response");
73+
});
74+
}
75+
76+
{
77+
// cookieSession();
78+
79+
// use(new Redis());
80+
//
81+
// session(RedisSessionStore.class);
82+
83+
get("/session", req -> {
84+
Session session = req.session();
85+
session.set("token", "value");
86+
return session.get("token").value();
87+
});
88+
}
89+
90+
public static void main(final String[] args) {
91+
92+
run(App::new, args);
93+
}
94+
95+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.baeldung.jooby.bean;
2+
3+
public class Employee {
4+
5+
String id;
6+
String name;
7+
String email;
8+
String phone;
9+
String address;
10+
11+
public Employee(String id, String name, String email, String phone, String address) {
12+
super();
13+
this.id = id;
14+
this.name = name;
15+
this.email = email;
16+
this.phone = phone;
17+
this.address = address;
18+
}
19+
20+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.baeldung.jooby.mvc;
2+
3+
import org.jooby.Result;
4+
import org.jooby.Results;
5+
import org.jooby.mvc.GET;
6+
import org.jooby.mvc.Path;
7+
8+
@Path("/hello")
9+
public class GetController {
10+
11+
@GET
12+
public String hello() {
13+
return "Hello Baeldung";
14+
}
15+
16+
@GET
17+
@Path("/home")
18+
public Result home() {
19+
return Results.html("welcome").put("model", new Object());
20+
}
21+
22+
}

0 commit comments

Comments
 (0)