From acd7d764e29b79ca85bed45d3faeec54e2a7bc29 Mon Sep 17 00:00:00 2001 From: Anshul BANSAL Date: Tue, 18 Feb 2020 10:50:53 +0200 Subject: [PATCH] Initial commit --- libraries-3/pom.xml | 36 +++++++++++++++++++ .../java/com/baeldung/takes/TakesApp.java | 26 ++++++++++++++ .../java/com/baeldung/takes/TakesIndex.java | 25 +++++++++++++ .../com/baeldung/takes/TakesServletApp.java | 23 ++++++++++++ .../main/java/com/baeldung/takes/TkRoute.java | 15 ++++++++ 5 files changed, 125 insertions(+) create mode 100644 libraries-3/src/main/java/com/baeldung/takes/TakesApp.java create mode 100644 libraries-3/src/main/java/com/baeldung/takes/TakesIndex.java create mode 100644 libraries-3/src/main/java/com/baeldung/takes/TakesServletApp.java create mode 100644 libraries-3/src/main/java/com/baeldung/takes/TkRoute.java diff --git a/libraries-3/pom.xml b/libraries-3/pom.xml index 66b48733f2..d345ff8f19 100644 --- a/libraries-3/pom.xml +++ b/libraries-3/pom.xml @@ -73,6 +73,11 @@ ${cache2k.version} pom + + org.takes + takes + 1.19 + @@ -81,6 +86,37 @@ https://jitpack.io + + + + hit-refresh + + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + + start-server + pre-integration-test + + java + + + + + com.baeldung.takes.TakesApp + false + + --port=${port} + + + + + + + 1.78 diff --git a/libraries-3/src/main/java/com/baeldung/takes/TakesApp.java b/libraries-3/src/main/java/com/baeldung/takes/TakesApp.java new file mode 100644 index 0000000000..f1a7149349 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/takes/TakesApp.java @@ -0,0 +1,26 @@ +package com.baeldung.takes; + +import org.takes.http.Exit; +import org.takes.http.FtBasic; +import org.takes.http.FtCli; +import org.takes.tk.TkClasspath; +import org.takes.tk.TkWrap; +import org.takes.Take; +import org.takes.facets.fork.FkRegex; +import org.takes.facets.fork.TkFork; + +public final class TakesApp { + + + +// public static void main(final String... args) throws Exception { +// new FtBasic(new TkFork(new FkRegex("/", "hello, world... this is coming from Takes!")), 6060).start(Exit.NEVER); +// } + + public static void main(final String... args) throws Exception { + new FtBasic(new TakesIndex(), 6060).start(Exit.NEVER); + } + + + +} \ No newline at end of file diff --git a/libraries-3/src/main/java/com/baeldung/takes/TakesIndex.java b/libraries-3/src/main/java/com/baeldung/takes/TakesIndex.java new file mode 100644 index 0000000000..646b886abb --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/takes/TakesIndex.java @@ -0,0 +1,25 @@ +package com.baeldung.takes; + +import java.io.IOException; + +import org.takes.Request; +import org.takes.Response; +import org.takes.Take; +import org.takes.rs.RsVelocity; +import org.takes.rs.RsWithBody; +import org.takes.rs.RsWithStatus; +import org.takes.rs.RsWithType; + +public final class TakesIndex implements Take { + +// @Override +// public Response act(Request req) throws IOException { +// return new RsWithStatus(new RsWithType(new RsWithBody("Hello, world!"), "text/html"), 200); +// } + + @Override + public Response act(Request req) { + return new RsVelocity("Hello, ${name}", new RsVelocity.Pair("name", "Jeffrey")); + } + +} diff --git a/libraries-3/src/main/java/com/baeldung/takes/TakesServletApp.java b/libraries-3/src/main/java/com/baeldung/takes/TakesServletApp.java new file mode 100644 index 0000000000..93951130f7 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/takes/TakesServletApp.java @@ -0,0 +1,23 @@ +package com.baeldung.takes; + +import javax.servlet.ServletContext; + +import org.takes.Request; +import org.takes.Response; +import org.takes.Take; +import org.takes.rs.RsText; + +public final class TakesServletApp implements Take { + + private final ServletContext ctx; + + public TakesServletApp(final ServletContext context) { + this.ctx = context; + } + + @Override + public Response act(final Request req) { + return new RsText("Hello servlet!"); + } +} + diff --git a/libraries-3/src/main/java/com/baeldung/takes/TkRoute.java b/libraries-3/src/main/java/com/baeldung/takes/TkRoute.java new file mode 100644 index 0000000000..849aaa8240 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/takes/TkRoute.java @@ -0,0 +1,15 @@ +package com.baeldung.takes; + +import org.takes.Request; +import org.takes.Response; +import org.takes.Take; +import org.takes.rs.RsText; + +public final class TkRoute implements Take { + + @Override + public Response act(final Request request) { + return new RsText("Hello, world!"); + } + +}