forked from jooby-project/jooby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDispatchApp.java
More file actions
38 lines (29 loc) · 863 Bytes
/
Copy pathDispatchApp.java
File metadata and controls
38 lines (29 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Jooby https://jooby.io
* Apache License Version 2.0 https://jooby.io/LICENSE.txt
* Copyright 2014 Edgar Espina
*/
package examples;
import io.jooby.ExecutionMode;
import io.jooby.Jooby;
import java.util.concurrent.Executors;
public class DispatchApp extends Jooby {
{
setWorker(Executors.newCachedThreadPool());
decorator(next -> ctx -> {
System.out.println(Thread.currentThread().getName());
return next.apply(ctx);
});
get("/", ctx -> ctx.query("n").intValue(2));
dispatch(() -> {
get("/worker", ctx -> ctx.query("n").intValue(2));
});
executor("single", Executors.newSingleThreadExecutor());
dispatch(() -> {
get("/worker", ctx -> ctx.query("n").intValue(2));
});
}
public static void main(String[] args) {
runApp(args, ExecutionMode.EVENT_LOOP, DispatchApp::new);
}
}