Browse Source

Merge undertow-jersey-c3p0 and undertow-jersey-hikaricp (#3333)

* Merge undertow-jersey-c3p0 and undertow-jersey-hikaricp. Rename project to undertow-jersey

* Fix maven command in hikaricp.sh

* Fix hikaricp maven profile name

* Turn off JDBC URL search and replace
Radoslav Petrov 7 years ago
parent
commit
b71960cd72
44 changed files with 118 additions and 890 deletions
  1. 1 2
      .travis.yml
  2. 0 28
      frameworks/Java/undertow-jersey-c3p0/benchmark_config.json
  3. 0 137
      frameworks/Java/undertow-jersey-c3p0/pom.xml
  4. 0 1
      frameworks/Java/undertow-jersey-hikaricp/.gitignore
  5. 0 29
      frameworks/Java/undertow-jersey-hikaricp/README.md
  6. 0 27
      frameworks/Java/undertow-jersey-hikaricp/benchmark_config.json
  7. 0 18
      frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/Common.java
  8. 0 80
      frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/DbResource.java
  9. 0 44
      frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/FortunesResource.java
  10. 0 79
      frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/JerseyWebServer.java
  11. 0 50
      frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/JsonMessageBodyWriter.java
  12. 0 22
      frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/JsonResource.java
  13. 0 18
      frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/PlaintextResource.java
  14. 0 20
      frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/RequestExceptionMapper.java
  15. 0 19
      frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/ServerResponseFilter.java
  16. 0 45
      frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/SessionFactoryProvider.java
  17. 0 30
      frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/domain/Fortune.java
  18. 0 14
      frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/domain/World.java
  19. 0 75
      frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/undertow/UndertowContainerResponseWriter.java
  20. 0 111
      frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/undertow/UndertowJerseyContainer.java
  21. 0 20
      frameworks/Java/undertow-jersey-hikaricp/src/main/resources/fortunes.mustache
  22. 0 0
      frameworks/Java/undertow-jersey/.gitignore
  23. 2 2
      frameworks/Java/undertow-jersey/README.md
  24. 48 0
      frameworks/Java/undertow-jersey/benchmark_config.json
  25. 1 1
      frameworks/Java/undertow-jersey/hikaricp.sh
  26. 59 11
      frameworks/Java/undertow-jersey/pom.xml
  27. 0 0
      frameworks/Java/undertow-jersey/setup.sh
  28. 0 0
      frameworks/Java/undertow-jersey/src/main/java/hello/Common.java
  29. 0 0
      frameworks/Java/undertow-jersey/src/main/java/hello/DbResource.java
  30. 0 0
      frameworks/Java/undertow-jersey/src/main/java/hello/FortunesResource.java
  31. 0 0
      frameworks/Java/undertow-jersey/src/main/java/hello/JerseyWebServer.java
  32. 0 0
      frameworks/Java/undertow-jersey/src/main/java/hello/JsonMessageBodyWriter.java
  33. 0 0
      frameworks/Java/undertow-jersey/src/main/java/hello/JsonResource.java
  34. 0 0
      frameworks/Java/undertow-jersey/src/main/java/hello/PlaintextResource.java
  35. 0 0
      frameworks/Java/undertow-jersey/src/main/java/hello/RequestExceptionMapper.java
  36. 0 0
      frameworks/Java/undertow-jersey/src/main/java/hello/ServerResponseFilter.java
  37. 5 5
      frameworks/Java/undertow-jersey/src/main/java/hello/SessionFactoryProvider.java
  38. 0 0
      frameworks/Java/undertow-jersey/src/main/java/hello/domain/Fortune.java
  39. 0 0
      frameworks/Java/undertow-jersey/src/main/java/hello/domain/World.java
  40. 0 0
      frameworks/Java/undertow-jersey/src/main/java/hello/undertow/UndertowContainerResponseWriter.java
  41. 0 0
      frameworks/Java/undertow-jersey/src/main/java/hello/undertow/UndertowJerseyContainer.java
  42. 0 0
      frameworks/Java/undertow-jersey/src/main/resources/fortunes.mustache
  43. 1 1
      frameworks/Java/undertow-jersey/src/main/resources/hibernate.cfg.xml
  44. 1 1
      frameworks/Java/undertow-jersey/src/main/resources/hikarycp/hibernate.cfg.xml

+ 1 - 2
.travis.yml

@@ -105,8 +105,7 @@ env:
     - "TESTDIR=Java/spring"
     - "TESTDIR=Java/tapestry"
     - "TESTDIR=Java/undertow"
-    - "TESTDIR=Java/undertow-jersey-c3p0"
-    - "TESTDIR=Java/undertow-jersey-hikaricp"
+    - "TESTDIR=Java/undertow-jersey"
     - "TESTDIR=Java/vertx"
     - "TESTDIR=Java/vertx-web"
     - "TESTDIR=Java/wicket"

+ 0 - 28
frameworks/Java/undertow-jersey-c3p0/benchmark_config.json

@@ -1,28 +0,0 @@
-{
-  "framework": "undertow-jersey-c3p0",
-  "tests": [{
-    "default": {
-      "setup_file": "setup",
-      "json_url": "/json",
-      "db_url": "/db?single=true",
-      "query_url": "/db?queries=",
-      "fortune_url": "/fortunes",
-      "plaintext_url": "/plaintext",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Platform",
-      "database": "MySQL",
-      "framework": "Jersey",
-      "language": "Java",
-      "flavor": "None",
-      "orm": "Full",
-      "platform": "JAX-RS",
-      "webserver": "None",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Undertow",
-      "notes": "",
-      "versus": "undertow-jersey-hikaricp"
-    }
-  }]
-}

+ 0 - 137
frameworks/Java/undertow-jersey-c3p0/pom.xml

@@ -1,137 +0,0 @@
-<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.techempower</groupId>
-  <artifactId>undertow-jersey</artifactId>
-  <version>0.1</version>
-
-  <packaging>jar</packaging>
-
-  <prerequisites>
-    <maven>3.0</maven>
-  </prerequisites>
-
-
-  <properties>
-    <jersey.version>2.22.1</jersey.version>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
-
-  <dependencyManagement>
-    <dependencies>
-      <dependency>
-        <groupId>org.glassfish.jersey</groupId>
-        <artifactId>jersey-bom</artifactId>
-        <version>${jersey.version}</version>
-        <type>pom</type>
-        <scope>import</scope>
-      </dependency>
-    </dependencies>
-  </dependencyManagement>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.glassfish.jersey.core</groupId>
-      <artifactId>jersey-server</artifactId>
-      <version>${jersey.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.glassfish.jersey.core</groupId>
-      <artifactId>jersey-server</artifactId>
-      <version>${jersey.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.glassfish.jersey.ext</groupId>
-      <artifactId>jersey-mvc-mustache</artifactId>
-      <version>${jersey.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.glassfish.jersey.media</groupId>
-      <artifactId>jersey-media-json-jackson</artifactId>
-      <version>${jersey.version}</version>
-    </dependency>
-
-    <dependency>
-      <groupId>org.hibernate</groupId>
-      <artifactId>hibernate-core</artifactId>
-      <version>4.3.11.Final</version>
-    </dependency>
-    <dependency>
-      <groupId>org.hibernate</groupId>
-      <artifactId>hibernate-c3p0</artifactId>
-      <version>4.3.11.Final</version>
-    </dependency>
-
-    <dependency>
-      <groupId>commons-cli</groupId>
-      <artifactId>commons-cli</artifactId>
-      <version>1.2</version>
-    </dependency>
-
-    <dependency>
-      <groupId>mysql</groupId>
-      <artifactId>mysql-connector-java</artifactId>
-      <version>5.1.38</version>
-    </dependency>
-
-    <dependency>
-      <groupId>io.undertow</groupId>
-      <artifactId>undertow-core</artifactId>
-      <version>1.3.11.Final</version>
-    </dependency>
-
-    <dependency>
-      <groupId>javax.xml.bind</groupId>
-      <artifactId>jaxb-api</artifactId>
-      <version>2.2.12</version>
-    </dependency>
-
-    <dependency>
-      <groupId>javax.activation</groupId>
-      <artifactId>activation</artifactId>
-      <version>1.1.1</version>
-    </dependency>
-
-  </dependencies>
-
-  <build>
-    <finalName>${project.artifactId}</finalName>
-    <plugins>
-      <plugin>
-        <inherited>true</inherited>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <version>3.1</version>
-        <configuration>
-          <source>1.7</source>
-          <target>1.7</target>
-          <optimize>true</optimize>
-          <debug>false</debug>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-shade-plugin</artifactId>
-        <version>2.1</version>
-        <executions>
-          <execution>
-            <phase>package</phase>
-            <goals>
-              <goal>shade</goal>
-            </goals>
-            <configuration>
-              <transformers>
-                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
-                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
-                  <mainClass>hello.JerseyWebServer</mainClass>
-                </transformer>
-              </transformers>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-</project>

+ 0 - 1
frameworks/Java/undertow-jersey-hikaricp/.gitignore

@@ -1 +0,0 @@
-/dependency-reduced-pom.xml

+ 0 - 29
frameworks/Java/undertow-jersey-hikaricp/README.md

@@ -1,29 +0,0 @@
-# Undertow + Jersey + Hikaricp Benchmarking Test
-### Heavily borrowed from the grizzly-jersey test
-
-This is the Undertow+Jersey portion of a [benchmarking test suite](../) comparing a variety of web development platforms.
-
-### JSON serialization test
-* [JSON test resource](src/main/java/hello/JsonResource.java)
-
-### Database tests
-* [Database tests resource](src/main/java/hello/DbResource.java)
-
-### Fortunes test
-* [Fortunes test resource](src/main/java/hello/FortunesResource.java)
-
-## Test URLs
-
-### JSON serialization test
-
-    http://localhost:8080/json
-
-### Database tests
-
-    http://localhost:8080/db
-
-    http://localhost:8080/db?queries=10
-
-### Fortunes test
-
-    http://localhost:8080/fortunes

+ 0 - 27
frameworks/Java/undertow-jersey-hikaricp/benchmark_config.json

@@ -1,27 +0,0 @@
-{
-  "framework": "undertow-jersey-hikaricp",
-  "tests": [{
-    "default": {
-      "setup_file": "setup",
-      "json_url": "/json",
-      "db_url": "/db?single=true",
-      "query_url": "/db?queries=",
-      "fortune_url": "/fortunes",
-      "plaintext_url": "/plaintext",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Platform",
-      "database": "MySQL",
-      "framework": "Jersey",
-      "language": "Java",
-      "orm": "Full",
-      "platform": "JAX-RS",
-      "webserver": "None",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Undertow-hikaricp",
-      "notes": "",
-      "versus": "undertow-jersey-c3p0"
-    }
-  }]
-}

+ 0 - 18
frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/Common.java

@@ -1,18 +0,0 @@
-package hello;
-
-import java.util.concurrent.*;
-
-/**
- * @author denkab
- */
-public class Common
-{
-
-  private static final int cpuCount = Runtime.getRuntime().availableProcessors();
-
-  public static ExecutorService EXECUTOR = new ThreadPoolExecutor(
-      cpuCount * 2, cpuCount * 25, 200, TimeUnit.MILLISECONDS,
-      new LinkedBlockingQueue<Runnable>(cpuCount * 100),
-      new ThreadPoolExecutor.CallerRunsPolicy());
-
-}

+ 0 - 80
frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/DbResource.java

@@ -1,80 +0,0 @@
-package hello;
-
-import hello.domain.*;
-import org.hibernate.*;
-
-import javax.inject.*;
-import javax.ws.rs.*;
-import java.util.*;
-import java.util.concurrent.*;
-
-import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
-
-@Singleton
-@Path("/db")
-public class DbResource
-{
-
-  private static final int DB_ROWS = 10000;
-
-  @Inject
-  private SessionFactory sessionFactory;
-
-  @GET
-  @Produces(APPLICATION_JSON)
-  public Object db(@QueryParam("queries") String queryParam,
-      @QueryParam("single") boolean isSingle)
-      throws ExecutionException, InterruptedException
-  {
-
-    final int queries = getQueries(queryParam);
-    final World[] worlds = new World[queries];
-    final Random random = ThreadLocalRandom.current();
-
-    Map<Integer, Future<World>> futureWorlds = new ConcurrentHashMap<>();
-    for (int i = 0; i < queries; i++)
-    {
-      futureWorlds.put(i, Common.EXECUTOR.submit(new Callable<World>()
-      {
-        @Override
-        public World call() throws Exception
-        {
-          Session session = sessionFactory.openSession();
-          session.setDefaultReadOnly(true);
-
-          try
-          {
-            return (World)session.byId(World.class).load(
-                random.nextInt(DB_ROWS) + 1);
-          }
-          finally
-          {
-            session.close();
-          }
-        }
-      }));
-    }
-
-    for (int i = 0; i < queries; i++)
-    {
-      worlds[i] = futureWorlds.get(i).get();
-    }
-    return isSingle ? worlds[0] : worlds;
-  }
-
-  private int getQueries(String proto)
-  {
-    int result = 1;
-    try
-    {
-      if (proto != null && !proto.trim().isEmpty())
-      {
-        result = Integer.parseInt(proto);
-      }
-    }
-    catch (NumberFormatException e)
-    {/* by test contract */}
-
-    return Math.min(500, Math.max(1, result));
-  }
-}

+ 0 - 44
frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/FortunesResource.java

@@ -1,44 +0,0 @@
-package hello;
-
-import hello.domain.*;
-import org.glassfish.jersey.server.mvc.*;
-import org.hibernate.*;
-
-import javax.inject.*;
-import javax.ws.rs.*;
-import java.util.*;
-
-import static javax.ws.rs.core.MediaType.TEXT_HTML;
-
-@Singleton
-@Path("/fortunes")
-public class FortunesResource
-{
-
-  @Inject
-  private SessionFactory sessionFactory;
-
-  @GET
-  @Produces(TEXT_HTML + "; charset=utf-8")
-  public Viewable fortunes()
-  {
-    final Session session = sessionFactory.openSession();
-    final List<Fortune> fortunes = new ArrayList<>(
-        session.createCriteria(Fortune.class).list());
-    fortunes.add(new Fortune(0, "Additional fortune added at request time."));
-    Collections.sort(fortunes);
-
-    session.close();
-    return new Viewable("/fortunes.mustache", new Scope(fortunes));
-  }
-
-  public static class Scope
-  {
-    public List fortunes;
-
-    public Scope(final List fortunes)
-    {
-      this.fortunes = fortunes;
-    }
-  }
-}

+ 0 - 79
frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/JerseyWebServer.java

@@ -1,79 +0,0 @@
-package hello;
-
-import hello.undertow.*;
-import io.undertow.*;
-import io.undertow.server.handlers.*;
-import org.apache.commons.cli.*;
-import org.glassfish.hk2.utilities.binding.*;
-import org.glassfish.jersey.server.*;
-import org.hibernate.*;
-
-import javax.inject.*;
-import java.util.*;
-
-public class JerseyWebServer
-{
-  private final int    port;
-  private final String dbHost;
-  private final int    dbPort;
-
-  public JerseyWebServer(final int port, final String dbHost,
-      final int dbPort)
-  {
-    this.port = port;
-    this.dbHost = dbHost;
-    this.dbPort = dbPort;
-  }
-
-  public static void main(final String[] args) throws Exception
-  {
-    CommandLineParser parser = new BasicParser();
-    CommandLine cmd = parser.parse(options(), args);
-
-    final int port = Integer.parseInt(cmd.getOptionValue("port", "8080"));
-    final String dbHost = cmd.getOptionValue("dbhost", "localhost");
-    final int dbPort = Integer.parseInt(cmd.getOptionValue("dbport", "3306"));
-
-    ResourceConfig config = new ResourceConfig(DbResource.class,
-        FortunesResource.class, JsonResource.class, PlaintextResource.class,
-        JsonMessageBodyWriter.class, ServerResponseFilter.class, RequestExceptionMapper.class);
-
-    config.setProperties(new HashMap<String, Object>()
-    {{
-      put("dbhost", dbHost);
-
-      put("dbport", dbPort);
-    }});
-
-    config.register(org.glassfish.jersey.server.mvc.MvcFeature.class);
-    config.register(
-        org.glassfish.jersey.server.mvc.mustache.MustacheMvcFeature.class);
-
-    config.register(new AbstractBinder()
-    {
-      @Override
-      protected void configure()
-      {
-        bindFactory(SessionFactoryProvider.class).to(SessionFactory.class).in(
-          Singleton.class);
-      }
-    });
-
-    UndertowJerseyContainer container = new UndertowJerseyContainer(config);
-
-    BlockingHandler bh = new BlockingHandler(container);
-
-    Undertow server = Undertow.builder().addHttpListener(port,
-        "0.0.0.0").setHandler(bh).build();
-    server.start();
-  }
-
-  private static Options options()
-  {
-    Options options = new Options();
-    options.addOption("port", true, "server port");
-    options.addOption("dbhost", true, "database host");
-    options.addOption("dbport", true, "database port");
-    return options;
-  }
-}

+ 0 - 50
frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/JsonMessageBodyWriter.java

@@ -1,50 +0,0 @@
-package hello;
-
-import com.fasterxml.jackson.databind.*;
-
-import javax.inject.*;
-import javax.ws.rs.*;
-import javax.ws.rs.core.*;
-import javax.ws.rs.ext.*;
-import javax.ws.rs.ext.Provider;
-import java.io.*;
-import java.lang.annotation.*;
-import java.lang.reflect.*;
-
-import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
-
-@Provider
-@Singleton
-@Produces(APPLICATION_JSON)
-public class JsonMessageBodyWriter
-    implements MessageBodyWriter<Object>
-{
-
-  private final ObjectMapper mapper = new ObjectMapper();
-
-  @Override
-  public boolean isWriteable(final Class<?> type, final Type genericType,
-      final Annotation[] annotations, final MediaType mediaType)
-  {
-    return "json".equals(mediaType.getSubtype());
-  }
-
-  @Override
-  public long getSize(final Object t, final Class<?> type,
-      final Type genericType, final Annotation[] annotations,
-      final MediaType mediaType)
-  {
-    return -1; // We can't predict the output size at this point
-  }
-
-  @Override
-  public void writeTo(final Object t, final Class<?> type,
-      final Type genericType, final Annotation[] annotations,
-      final MediaType mediaType,
-      final MultivaluedMap<String, Object> httpHeaders,
-      final OutputStream entityStream)
-      throws IOException, WebApplicationException
-  {
-    mapper.writeValue(entityStream, t);
-  }
-}

+ 0 - 22
frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/JsonResource.java

@@ -1,22 +0,0 @@
-package hello;
-
-import javax.inject.*;
-import javax.ws.rs.*;
-import java.util.*;
-
-import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
-
-@Singleton
-@Path("/json")
-public class JsonResource
-{
-
-  @GET
-  @Produces(APPLICATION_JSON)
-  public Object json()
-  {
-    Map<String, String> data = new HashMap<String, String>(1);
-    data.put("message", "Hello, World!");
-    return data;
-  }
-}

+ 0 - 18
frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/PlaintextResource.java

@@ -1,18 +0,0 @@
-package hello;
-
-import javax.inject.*;
-import javax.ws.rs.*;
-import java.util.*;
-
-@Singleton
-@Path("/plaintext")
-public class PlaintextResource
-{
-
-  @GET
-  @Produces("text/plain")
-  public String plaintext()
-  {
-    return "Hello, World!";
-  }
-}

+ 0 - 20
frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/RequestExceptionMapper.java

@@ -1,20 +0,0 @@
-package hello;
-
-import javax.ws.rs.core.*;
-import javax.ws.rs.core.Response.*;
-import javax.ws.rs.ext.*;
-
-public class RequestExceptionMapper
-    implements ExceptionMapper<Exception>
-{
-//  private static final Logger LOGGER = LoggerFactory.getLogger(
-//      RequestExceptionMapper.class);
-
-  @Override
-  public Response toResponse(Exception exception)
-  {
-    exception.printStackTrace();
-    System.err.println(exception.toString());
-    return Response.status(Status.NOT_FOUND).build();
-  }
-}

+ 0 - 19
frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/ServerResponseFilter.java

@@ -1,19 +0,0 @@
-package hello;
-
-import javax.ws.rs.container.*;
-import java.io.*;
-
-public class ServerResponseFilter
-    implements ContainerResponseFilter
-{
-
-  private static final String SERVER_HEADER = "Server";
-  private static final String SERVER_VALUE  = "Undertow";
-
-  @Override
-  public void filter(ContainerRequestContext requestContext,
-      ContainerResponseContext responseContext) throws IOException
-  {
-    responseContext.getHeaders().add(SERVER_HEADER, SERVER_VALUE);
-  }
-}

+ 0 - 45
frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/SessionFactoryProvider.java

@@ -1,45 +0,0 @@
-package hello;
-
-import hello.domain.*;
-import org.glassfish.hk2.api.*;
-import org.hibernate.*;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.service.*;
-
-import javax.ws.rs.core.*;
-import javax.ws.rs.core.Context;
-
-public class SessionFactoryProvider
-    implements Factory<SessionFactory>
-{
-
-  @Context
-  Application application;
-
-  public SessionFactoryProvider()
-  {
-  }
-
-  @Override
-  public SessionFactory provide()
-  {
-    Configuration configuration = new Configuration().configure();
-    String url = configuration.getProperty("hibernate.hikari.dataSource.url");
-    url = url.replace("//localhost:3306/",
-        "//" + this.application.getProperties().get("dbhost") + ":"
-            + this.application.getProperties().get("dbport") + "/");
-    configuration.setProperty("hibernate.hikari.dataSource.url", url);
-    configuration.addAnnotatedClass(World.class);
-    configuration.addAnnotatedClass(Fortune.class);
-    ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder().applySettings(
-        configuration.getProperties());
-    return configuration.buildSessionFactory(
-        serviceRegistryBuilder.buildServiceRegistry());
-  }
-
-  @Override
-  public void dispose(SessionFactory instance)
-  {
-
-  }
-}

+ 0 - 30
frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/domain/Fortune.java

@@ -1,30 +0,0 @@
-package hello.domain;
-
-import javax.persistence.*;
-
-@Entity
-public class Fortune
-    implements Comparable<Fortune>
-{
-
-  @Id
-  @GeneratedValue(strategy = GenerationType.IDENTITY)
-  public int    id;
-  public String message;
-
-  public Fortune()
-  {
-  }
-
-  public Fortune(final int id, final String message)
-  {
-    this.id = id;
-    this.message = message;
-  }
-
-  @Override
-  public int compareTo(final Fortune other)
-  {
-    return message.compareTo(other.message);
-  }
-}

+ 0 - 14
frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/domain/World.java

@@ -1,14 +0,0 @@
-package hello.domain;
-
-import javax.persistence.*;
-
-@Entity
-public class World
-{
-
-  @Id
-  @GeneratedValue(strategy = GenerationType.IDENTITY)
-  public int id;
-  public int randomNumber;
-
-}

+ 0 - 75
frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/undertow/UndertowContainerResponseWriter.java

@@ -1,75 +0,0 @@
-package hello.undertow;
-
-import io.undertow.server.*;
-import io.undertow.util.*;
-import org.glassfish.jersey.server.*;
-import org.glassfish.jersey.server.spi.*;
-
-import java.io.*;
-import java.util.*;
-import java.util.concurrent.*;
-
-public class UndertowContainerResponseWriter
-    implements ContainerResponseWriter
-{
-  private HttpServerExchange httpServerExchange;
-
-  public UndertowContainerResponseWriter(
-      HttpServerExchange httpServerExchange)
-  {
-    this.httpServerExchange = httpServerExchange;
-  }
-
-  @Override
-  public OutputStream writeResponseStatusAndHeaders(long contentLength,
-      ContainerResponse responseContext) throws ContainerException
-  {
-    httpServerExchange.setStatusCode(responseContext.getStatus());
-
-    for (Map.Entry<String, List<String>> mapEntry : responseContext.getStringHeaders().entrySet())
-    {
-      httpServerExchange.getResponseHeaders().putAll(
-          new HttpString(mapEntry.getKey()), mapEntry.getValue());
-    }
-
-    httpServerExchange.setResponseContentLength(contentLength);
-    return httpServerExchange.getOutputStream();
-  }
-
-  @Override
-  public boolean suspend(long timeOut, TimeUnit timeUnit,
-      TimeoutHandler timeoutHandler)
-  {
-    // TODO implement
-    return false;
-  }
-
-  @Override
-  public void setSuspendTimeout(long timeOut, TimeUnit timeUnit)
-      throws IllegalStateException
-  {
-    //TODO implement
-  }
-
-  @Override
-  public void commit()
-  {
-    httpServerExchange.endExchange();
-  }
-
-  @Override
-  public void failure(Throwable error)
-  {
-    // TODO don't print out
-    httpServerExchange.setStatusCode(500);
-    httpServerExchange.endExchange();
-    error.printStackTrace();
-  }
-
-  @Override
-  public boolean enableResponseBuffering()
-  {
-    // TODO not sure
-    return false;
-  }
-}

+ 0 - 111
frameworks/Java/undertow-jersey-hikaricp/src/main/java/hello/undertow/UndertowJerseyContainer.java

@@ -1,111 +0,0 @@
-package hello.undertow;
-
-import io.undertow.server.*;
-import io.undertow.util.*;
-import org.glassfish.jersey.internal.*;
-import org.glassfish.jersey.server.*;
-import org.glassfish.jersey.server.spi.*;
-
-import javax.ws.rs.core.*;
-import java.net.*;
-import java.security.*;
-
-public class UndertowJerseyContainer
-    implements Container, HttpHandler
-{
-
-  /**
-   * Default dummy security context.
-   * Taken from Jersey's ApplicationHandler class
-   */
-  private static final SecurityContext DEFAULT_SECURITY_CONTEXT = new SecurityContext()
-  {
-
-    @Override
-    public boolean isUserInRole(final String role)
-    {
-      return false;
-    }
-
-    @Override
-    public boolean isSecure()
-    {
-      return false;
-    }
-
-    @Override
-    public Principal getUserPrincipal()
-    {
-      return null;
-    }
-
-    @Override
-    public String getAuthenticationScheme()
-    {
-      return null;
-    }
-  };
-  private ApplicationHandler applicationHandler;
-
-  public UndertowJerseyContainer(Application configuration)
-  {
-    this.applicationHandler = new ApplicationHandler(configuration);
-  }
-
-  @Override
-  public ResourceConfig getConfiguration()
-  {
-    return this.applicationHandler.getConfiguration();
-  }
-
-  @Override
-  public ApplicationHandler getApplicationHandler()
-  {
-    return this.applicationHandler;
-  }
-
-  @Override
-  public void reload()
-  {
-    reload(this.applicationHandler.getConfiguration());
-  }
-
-  @Override
-  public void reload(ResourceConfig configuration)
-  {
-
-    this.applicationHandler.onShutdown(this);
-
-    this.applicationHandler = new ApplicationHandler(configuration);
-
-    this.applicationHandler.onStartup(this);
-    this.applicationHandler.onReload(this);
-  }
-
-  @Override
-  public void handleRequest(final HttpServerExchange httpServerExchange)
-      throws Exception
-  {
-    String requestUri = httpServerExchange.getRequestURI();
-    if(httpServerExchange.getQueryString().length() > 0)
-    {
-      requestUri = requestUri + "?" + httpServerExchange.getQueryString();
-    }
-
-    final ContainerRequest request = new ContainerRequest(null,
-        URI.create(requestUri),
-        httpServerExchange.getRequestMethod().toString(),
-        DEFAULT_SECURITY_CONTEXT, new MapPropertiesDelegate());
-
-    request.setWriter(
-        new UndertowContainerResponseWriter(httpServerExchange));
-
-    for (HeaderValues values : httpServerExchange.getRequestHeaders())
-    {
-      request.headers(values.getHeaderName().toString(), values);
-    }
-
-    request.setEntityStream(httpServerExchange.getInputStream());
-    this.applicationHandler.handle(request);
-  }
-}

+ 0 - 20
frameworks/Java/undertow-jersey-hikaricp/src/main/resources/fortunes.mustache

@@ -1,20 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<title>Fortunes</title>
-</head>
-<body>
-<table>
-<tr>
-<th>id</th>
-<th>message</th>
-</tr>
-{{#fortunes}}
-<tr>
-<td>{{id}}</td>
-<td>{{message}}</td>
-</tr>
-{{/fortunes}}
-</table>
-</body>
-</html>

+ 0 - 0
frameworks/Java/undertow-jersey-c3p0/.gitignore → frameworks/Java/undertow-jersey/.gitignore


+ 2 - 2
frameworks/Java/undertow-jersey-c3p0/README.md → frameworks/Java/undertow-jersey/README.md

@@ -1,7 +1,7 @@
-# Undertow + Jersey + c3p0 Benchmarking Test
+# Undertow + Jersey Benchmarking Test
 ### Heavily borrowed from the grizzly-jersey test
 
-This is the Undertow+Jersey portion of a [benchmarking test suite](../) comparing a variety of web development platforms.
+This is the Undertow+Jersey portion of a [benchmarking test suite](../) comparing a variety of web development platforms. The project is using two SQL connection pools: c3p0 and hikaricp.
 
 ### JSON serialization test
 * [JSON test resource](src/main/java/hello/JsonResource.java)

+ 48 - 0
frameworks/Java/undertow-jersey/benchmark_config.json

@@ -0,0 +1,48 @@
+{
+  "framework": "undertow-jersey",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/json",
+      "db_url": "/db?single=true",
+      "query_url": "/db?queries=",
+      "fortune_url": "/fortunes",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Platform",
+      "database": "MySQL",
+      "framework": "Jersey",
+      "language": "Java",
+      "flavor": "None",
+      "orm": "Full",
+      "platform": "JAX-RS",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "undertow-jersey-c3p0",
+      "notes": "",
+      "versus": "servlet-raw"
+    },
+    "hikaricp": {
+      "setup_file": "hikaricp",
+      "db_url": "/db?single=true",
+      "query_url": "/db?queries=",
+      "fortune_url": "/fortunes",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Platform",
+      "database": "MySQL",
+      "framework": "Jersey",
+      "language": "Java",
+      "orm": "Full",
+      "platform": "JAX-RS",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "undertow-jersey-hikaricp",
+      "notes": "",
+      "versus": "undertow-jersey"
+    }
+  }]
+}

+ 1 - 1
frameworks/Java/undertow-jersey-hikaricp/setup.sh → frameworks/Java/undertow-jersey/hikaricp.sh

@@ -2,6 +2,6 @@
 
 fw_depends mysql java maven
 
-mvn clean package
+mvn clean package -P hikaricp
 
 java -jar target/undertow-jersey.jar -dbhost ${DBHOST} &

+ 59 - 11
frameworks/Java/undertow-jersey-hikaricp/pom.xml → frameworks/Java/undertow-jersey/pom.xml

@@ -13,12 +13,70 @@
     <maven>3.0</maven>
   </prerequisites>
 
-
   <properties>
     <jersey.version>2.22.1</jersey.version>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>
 
+  <profiles>
+    <profile>
+      <id>c3p0</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>org.hibernate</groupId>
+          <artifactId>hibernate-c3p0</artifactId>
+          <version>4.3.11.Final</version>
+        </dependency>
+      </dependencies>
+      <build>
+        <resources>
+          <resource>
+            <directory>src/main/resources/</directory>
+            <includes>
+              <include>fortunes.mustache</include>
+              <include>hibernate.cfg.xml</include>
+            </includes>
+            <excludes>
+              <exclude>hikarycp/hibernate.cfg.xml</exclude>
+            </excludes>
+          </resource>
+        </resources>
+      </build>
+    </profile>
+    <profile>
+      <id>hikaricp</id>
+      <dependencies>
+        <dependency>
+          <groupId>org.hibernate</groupId>
+          <artifactId>hibernate-hikaricp</artifactId>
+          <version>4.3.11.Final</version>
+        </dependency>
+      </dependencies>
+      <build>
+        <resources>
+          <resource>
+            <directory>src/main/resources/</directory>
+            <includes>
+              <include>fortunes.mustache</include>
+            </includes>
+            <excludes>
+              <exclude>hibernate.cfg.xml</exclude>
+            </excludes>
+          </resource>
+          <resource>
+            <directory>src/main/resources/hikarycp</directory>
+            <includes>
+              <include>hibernate.cfg.xml</include>
+            </includes>
+          </resource>
+        </resources>
+      </build>
+    </profile>
+  </profiles>
+
   <dependencyManagement>
     <dependencies>
       <dependency>
@@ -32,11 +90,6 @@
   </dependencyManagement>
 
   <dependencies>
-    <dependency>
-      <groupId>org.glassfish.jersey.core</groupId>
-      <artifactId>jersey-server</artifactId>
-      <version>${jersey.version}</version>
-    </dependency>
     <dependency>
       <groupId>org.glassfish.jersey.core</groupId>
       <artifactId>jersey-server</artifactId>
@@ -58,11 +111,6 @@
       <artifactId>hibernate-core</artifactId>
       <version>4.3.11.Final</version>
     </dependency>
-    <dependency>
-      <groupId>org.hibernate</groupId>
-      <artifactId>hibernate-hikaricp</artifactId>
-      <version>4.3.11.Final</version>
-    </dependency>
 
     <dependency>
       <groupId>commons-cli</groupId>

+ 0 - 0
frameworks/Java/undertow-jersey-c3p0/setup.sh → frameworks/Java/undertow-jersey/setup.sh


+ 0 - 0
frameworks/Java/undertow-jersey-c3p0/src/main/java/hello/Common.java → frameworks/Java/undertow-jersey/src/main/java/hello/Common.java


+ 0 - 0
frameworks/Java/undertow-jersey-c3p0/src/main/java/hello/DbResource.java → frameworks/Java/undertow-jersey/src/main/java/hello/DbResource.java


+ 0 - 0
frameworks/Java/undertow-jersey-c3p0/src/main/java/hello/FortunesResource.java → frameworks/Java/undertow-jersey/src/main/java/hello/FortunesResource.java


+ 0 - 0
frameworks/Java/undertow-jersey-c3p0/src/main/java/hello/JerseyWebServer.java → frameworks/Java/undertow-jersey/src/main/java/hello/JerseyWebServer.java


+ 0 - 0
frameworks/Java/undertow-jersey-c3p0/src/main/java/hello/JsonMessageBodyWriter.java → frameworks/Java/undertow-jersey/src/main/java/hello/JsonMessageBodyWriter.java


+ 0 - 0
frameworks/Java/undertow-jersey-c3p0/src/main/java/hello/JsonResource.java → frameworks/Java/undertow-jersey/src/main/java/hello/JsonResource.java


+ 0 - 0
frameworks/Java/undertow-jersey-c3p0/src/main/java/hello/PlaintextResource.java → frameworks/Java/undertow-jersey/src/main/java/hello/PlaintextResource.java


+ 0 - 0
frameworks/Java/undertow-jersey-c3p0/src/main/java/hello/RequestExceptionMapper.java → frameworks/Java/undertow-jersey/src/main/java/hello/RequestExceptionMapper.java


+ 0 - 0
frameworks/Java/undertow-jersey-c3p0/src/main/java/hello/ServerResponseFilter.java → frameworks/Java/undertow-jersey/src/main/java/hello/ServerResponseFilter.java


+ 5 - 5
frameworks/Java/undertow-jersey-c3p0/src/main/java/hello/SessionFactoryProvider.java → frameworks/Java/undertow-jersey/src/main/java/hello/SessionFactoryProvider.java

@@ -24,11 +24,11 @@ public class SessionFactoryProvider
   public SessionFactory provide()
   {
     Configuration configuration = new Configuration().configure();
-    String url = configuration.getProperty("hibernate.connection.url");
-    url = url.replace("//localhost:3306/",
-        "//" + this.application.getProperties().get("dbhost") + ":"
-            + this.application.getProperties().get("dbport") + "/");
-    configuration.setProperty("hibernate.connection.url", url);
+//    String url = configuration.getProperty("hibernate.connection.url");
+//    url = url.replace("//localhost:3306/",
+//        "//" + this.application.getProperties().get("dbhost") + ":"
+//            + this.application.getProperties().get("dbport") + "/");
+//    configuration.setProperty("hibernate.connection.url", url);
     configuration.addAnnotatedClass(World.class);
     configuration.addAnnotatedClass(Fortune.class);
     ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder().applySettings(

+ 0 - 0
frameworks/Java/undertow-jersey-c3p0/src/main/java/hello/domain/Fortune.java → frameworks/Java/undertow-jersey/src/main/java/hello/domain/Fortune.java


+ 0 - 0
frameworks/Java/undertow-jersey-c3p0/src/main/java/hello/domain/World.java → frameworks/Java/undertow-jersey/src/main/java/hello/domain/World.java


+ 0 - 0
frameworks/Java/undertow-jersey-c3p0/src/main/java/hello/undertow/UndertowContainerResponseWriter.java → frameworks/Java/undertow-jersey/src/main/java/hello/undertow/UndertowContainerResponseWriter.java


+ 0 - 0
frameworks/Java/undertow-jersey-c3p0/src/main/java/hello/undertow/UndertowJerseyContainer.java → frameworks/Java/undertow-jersey/src/main/java/hello/undertow/UndertowJerseyContainer.java


+ 0 - 0
frameworks/Java/undertow-jersey-c3p0/src/main/resources/fortunes.mustache → frameworks/Java/undertow-jersey/src/main/resources/fortunes.mustache


+ 1 - 1
frameworks/Java/undertow-jersey-c3p0/src/main/resources/hibernate.cfg.xml → frameworks/Java/undertow-jersey/src/main/resources/hibernate.cfg.xml

@@ -2,7 +2,7 @@
 <hibernate-configuration>
   <session-factory>
     <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
-    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hello_world?useSSL=false&amp;jdbcCompliantTruncation=false&amp;elideSetAutoCommits=true&amp;useLocalSessionState=true&amp;cachePrepStmts=true&amp;cacheCallableStmts=true&amp;alwaysSendSetIsolation=false&amp;prepStmtCacheSize=4096&amp;cacheServerConfiguration=true&amp;prepStmtCacheSqlLimit=2048&amp;zeroDateTimeBehavior=convertToNull&amp;traceProtocol=false&amp;useUnbufferedInput=false&amp;useReadAheadInput=false&amp;maintainTimeStats=false&amp;useServerPrepStmts&amp;cacheRSMetadata=true</property>
+    <property name="hibernate.connection.url">jdbc:mysql://TFB-database:3306/hello_world?useSSL=false&amp;jdbcCompliantTruncation=false&amp;elideSetAutoCommits=true&amp;useLocalSessionState=true&amp;cachePrepStmts=true&amp;cacheCallableStmts=true&amp;alwaysSendSetIsolation=false&amp;prepStmtCacheSize=4096&amp;cacheServerConfiguration=true&amp;prepStmtCacheSqlLimit=2048&amp;zeroDateTimeBehavior=convertToNull&amp;traceProtocol=false&amp;useUnbufferedInput=false&amp;useReadAheadInput=false&amp;maintainTimeStats=false&amp;useServerPrepStmts&amp;cacheRSMetadata=true</property>
     <property name="hibernate.connection.username">benchmarkdbuser</property>
     <property name="hibernate.connection.password">benchmarkdbpass</property>
     <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

+ 1 - 1
frameworks/Java/undertow-jersey-hikaricp/src/main/resources/hibernate.cfg.xml → frameworks/Java/undertow-jersey/src/main/resources/hikarycp/hibernate.cfg.xml

@@ -9,7 +9,7 @@
     <property name="hibernate.hikari.maximumPoolSize">256</property>
     <property name="hibernate.hikari.idleTimeout">30000</property>
     <property name="hibernate.hikari.dataSourceClassName">com.mysql.jdbc.jdbc2.optional.MysqlDataSource</property>
-    <property name="hibernate.hikari.dataSource.url">jdbc:mysql://localhost:3306/hello_world?jdbcCompliantTruncation=false&amp;elideSetAutoCommits=true&amp;useLocalSessionState=true&amp;cachePrepStmts=true&amp;cacheCallableStmts=true&amp;alwaysSendSetIsolation=false&amp;prepStmtCacheSize=4096&amp;cacheServerConfiguration=true&amp;prepStmtCacheSqlLimit=2048&amp;zeroDateTimeBehavior=convertToNull&amp;traceProtocol=false&amp;useUnbufferedInput=false&amp;useReadAheadInput=false&amp;maintainTimeStats=false&amp;useServerPrepStmts&amp;cacheRSMetadata=true&amp;useSSL=false</property>
+    <property name="hibernate.hikari.dataSource.url">jdbc:mysql://TFB-database:3306/hello_world?jdbcCompliantTruncation=false&amp;elideSetAutoCommits=true&amp;useLocalSessionState=true&amp;cachePrepStmts=true&amp;cacheCallableStmts=true&amp;alwaysSendSetIsolation=false&amp;prepStmtCacheSize=4096&amp;cacheServerConfiguration=true&amp;prepStmtCacheSqlLimit=2048&amp;zeroDateTimeBehavior=convertToNull&amp;traceProtocol=false&amp;useUnbufferedInput=false&amp;useReadAheadInput=false&amp;maintainTimeStats=false&amp;useServerPrepStmts&amp;cacheRSMetadata=true&amp;useSSL=false</property>
     <property name="hibernate.hikari.dataSource.user">benchmarkdbuser</property>
     <property name="hibernate.hikari.dataSource.password">benchmarkdbpass</property>
   </session-factory>