Initial commit

This commit is contained in:
Anshul BANSAL 2020-02-18 10:50:53 +02:00
parent 6dcb329bbc
commit acd7d764e2
5 changed files with 125 additions and 0 deletions

View File

@ -73,6 +73,11 @@
<version>${cache2k.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.takes</groupId>
<artifactId>takes</artifactId>
<version>1.19</version>
</dependency>
</dependencies>
<repositories>
@ -82,6 +87,37 @@
</repository>
</repositories>
<profiles>
<profile>
<id>hit-refresh</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>start-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.baeldung.takes.TakesApp</mainClass>
<cleanupDaemonThreads>false</cleanupDaemonThreads>
<arguments>
<argument>--port=${port}</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<properties>
<jcommander.version>1.78</jcommander.version>
<lombok.version>1.18.6</lombok.version>

View File

@ -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);
}
}

View File

@ -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("<html>Hello, world!</html>"), "text/html"), 200);
// }
@Override
public Response act(Request req) {
return new RsVelocity("Hello, ${name}", new RsVelocity.Pair("name", "Jeffrey"));
}
}

View File

@ -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!");
}
}

View File

@ -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!");
}
}