Browse Source

Merge branch 'master' into tarndt-master

Patrick Falls 12 years ago
parent
commit
3ef63d5987
40 changed files with 757 additions and 127 deletions
  1. 38 0
      django-optimized/README.md
  2. 0 0
      django-optimized/__init__.py
  3. 13 0
      django-optimized/benchmark_config
  4. 0 0
      django-optimized/hello/hello/__init__.py
  5. 168 0
      django-optimized/hello/hello/settings.py
  6. 19 0
      django-optimized/hello/hello/urls.py
  7. 28 0
      django-optimized/hello/hello/wsgi.py
  8. 10 0
      django-optimized/hello/manage.py
  9. 11 0
      django-optimized/hello/templates/base.html
  10. 0 0
      django-optimized/hello/world/__init__.py
  11. 9 0
      django-optimized/hello/world/models.py
  12. 25 0
      django-optimized/hello/world/views.py
  13. 23 0
      django-optimized/setup.py
  14. 2 4
      django/setup.py
  15. 17 0
      flask/README.md
  16. 0 0
      flask/__init__.py
  17. 38 0
      flask/app.py
  18. 13 0
      flask/benchmark_config
  19. 23 0
      flask/setup.py
  20. 17 2
      installer.py
  21. 0 1
      play-java/README.md
  22. 2 2
      play-java/setup.py
  23. 7 0
      play-scala/.gitignore
  24. 27 0
      play-scala/README.md
  25. 0 0
      play-scala/__init__.py
  26. 40 0
      play-scala/app/controllers/Application.scala
  27. 24 0
      play-scala/app/models/World.java
  28. 11 0
      play-scala/benchmark_config
  29. 74 0
      play-scala/conf/application.conf
  30. 10 0
      play-scala/conf/routes
  31. 23 0
      play-scala/project/Build.scala
  32. 1 0
      play-scala/project/build.properties
  33. 8 0
      play-scala/project/plugins.sbt
  34. 28 0
      play-scala/setup.py
  35. 8 16
      spring/src/main/java/hello/web/HelloDbController.java
  36. 25 16
      spring/src/main/java/hello/web/HelloJsonController.java
  37. 3 3
      spring/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml
  38. 6 0
      tapestry/hello/.gitignore
  39. 5 10
      tapestry/hello/build.gradle
  40. 1 73
      tapestry/hello/src/main/java/hello/services/AppModule.java

+ 38 - 0
django-optimized/README.md

@@ -0,0 +1,38 @@
+# Django Benchmarking Test
+
+This is the Django portion of a [benchmarking test suite](../) comparing a variety of web development platforms.
+
+### JSON Encoding Test
+
+* [JSON test source](hello/world/views.py)
+
+
+### Data-Store/Database Mapping Test
+
+* [DB test controller](hello/world/views.py)
+* [DB test model](hello/world/models.py)
+
+
+## Infrastructure Software Versions
+The tests were run with:
+* [Python 2.7.3](http://www.python.org/)
+* [Django 1.4](https://www.djangoproject.com/)
+* [Gunicorn 0.17.2](http://gunicorn.org/)
+* [MySQL 5.5.29](https://dev.mysql.com/)
+
+
+## Resources
+* https://docs.djangoproject.com/en/dev/intro/tutorial01/
+
+## Test URLs
+### JSON Encoding Test
+
+http://localhost:8080/json
+
+### Data-Store/Database Mapping Test
+
+http://localhost:8080/db
+
+### Variable Query Test
+
+http://localhost:8080/db?queries=2

+ 0 - 0
django-optimized/__init__.py


+ 13 - 0
django-optimized/benchmark_config

@@ -0,0 +1,13 @@
+{
+  "framework": "django-optimized",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/json",
+      "db_url": "/db",
+      "query_url": "/db?queries=",
+      "port": 8080,
+      "sort": 33
+    }
+  }]
+}

+ 0 - 0
django-optimized/hello/hello/__init__.py


+ 168 - 0
django-optimized/hello/hello/settings.py

@@ -0,0 +1,168 @@
+# Django settings for hello project.
+
+DEBUG = False
+TEMPLATE_DEBUG = DEBUG
+
+ADMINS = (
+    # ('Your Name', '[email protected]'),
+)
+
+MANAGERS = ADMINS
+
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
+        'NAME': 'hello_world',                      # Or path to database file if using sqlite3.
+        'USER': 'benchmarkdbuser',                      # Not used with sqlite3.
+        'PASSWORD': 'benchmarkdbpass',                  # Not used with sqlite3.
+        'HOST': 'localhost',                      # Set to empty string for localhost. Not used with sqlite3.
+        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
+    }
+}
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# On Unix systems, a value of None will cause Django to use the same
+# timezone as the operating system.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+TIME_ZONE = 'America/Chicago'
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'en-us'
+
+SITE_ID = 1
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = True
+
+# If you set this to False, Django will not format dates, numbers and
+# calendars according to the current locale.
+USE_L10N = True
+
+# If you set this to False, Django will not use timezone-aware datetimes.
+USE_TZ = True
+
+# Absolute filesystem path to the directory that will hold user-uploaded files.
+# Example: "/home/media/media.lawrence.com/media/"
+MEDIA_ROOT = ''
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash.
+# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
+MEDIA_URL = ''
+
+# Absolute path to the directory static files should be collected to.
+# Don't put anything in this directory yourself; store your static files
+# in apps' "static/" subdirectories and in STATICFILES_DIRS.
+# Example: "/home/media/media.lawrence.com/static/"
+STATIC_ROOT = ''
+
+# URL prefix for static files.
+# Example: "http://media.lawrence.com/static/"
+STATIC_URL = '/static/'
+
+# Additional locations of static files
+STATICFILES_DIRS = (
+    # Put strings here, like "/home/html/static" or "C:/www/django/static".
+    # Always use forward slashes, even on Windows.
+    # Don't forget to use absolute paths, not relative paths.
+)
+
+# List of finder classes that know how to find static files in
+# various locations.
+STATICFILES_FINDERS = (
+    'django.contrib.staticfiles.finders.FileSystemFinder',
+    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
+#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
+)
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = '_7mb6#v4yf@qhc(r(zbyh&z_iby-na*7wz&-v6pohsul-d#y5f'
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+    'django.template.loaders.filesystem.Loader',
+    'django.template.loaders.app_directories.Loader',
+)
+
+MIDDLEWARE_CLASSES = (
+    # In our optimized version, we can remove this middleware that we're not using
+    # 'django.middleware.common.CommonMiddleware',
+    # 'django.contrib.sessions.middleware.SessionMiddleware',
+    # 'django.middleware.csrf.CsrfViewMiddleware',
+    # 'django.contrib.auth.middleware.AuthenticationMiddleware',
+    # 'django.contrib.messages.middleware.MessageMiddleware',
+)
+
+ROOT_URLCONF = 'hello.urls'
+
+# Python dotted path to the WSGI application used by Django's runserver.
+WSGI_APPLICATION = 'hello.wsgi.application'
+
+TEMPLATE_DIRS = (
+    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
+    # Always use forward slashes, even on Windows.
+    # Don't forget to use absolute paths, not relative paths.
+    "/home/ubuntu/FrameworkBenchmarks/django/hello/templates",
+)
+
+INSTALLED_APPS = (
+    # Removing these for our optimized version
+    # 'django.contrib.auth',
+    # 'django.contrib.contenttypes',
+    # 'django.contrib.sessions',
+    # 'django.contrib.sites',
+    # 'django.contrib.messages',
+    # 'django.contrib.staticfiles',
+    # Uncomment the next line to enable the admin:
+    # 'django.contrib.admin',
+    # Uncomment the next line to enable admin documentation:
+    # 'django.contrib.admindocs',
+    'world',
+)
+
+# A sample logging configuration. The only tangible logging
+# performed by this configuration is to send an email to
+# the site admins on every HTTP 500 error when DEBUG=False.
+# See http://docs.djangoproject.com/en/dev/topics/logging for
+# more details on how to customize your logging configuration.
+LOGGING = {
+    'version': 1,
+    'disable_existing_loggers': True,
+    'formatters': {
+        'verbose': {
+            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
+        },
+        'simple': {
+            'format': '%(levelname)s %(message)s'
+        },
+    },
+    'filters': {
+        'require_debug_false': {
+            '()': 'django.utils.log.RequireDebugFalse'
+        }
+    },
+    'handlers': {
+        'mail_admins': {
+            'level': 'ERROR',
+            'filters': ['require_debug_false'],
+            'class': 'django.utils.log.AdminEmailHandler'
+        },
+        'console':{
+            'level': 'ERROR',
+            'class': 'logging.StreamHandler',
+            'formatter': 'simple'
+        },
+    },
+    'loggers': {
+        'django.request': {
+            'handlers': ['mail_admins', 'console'],
+            'level': 'ERROR',
+            'propagate': True,
+        },
+    }
+}

+ 19 - 0
django-optimized/hello/hello/urls.py

@@ -0,0 +1,19 @@
+from django.conf.urls import patterns, include, url
+
+# Uncomment the next two lines to enable the admin:
+# from django.contrib import admin
+# admin.autodiscover()
+
+urlpatterns = patterns('',
+    # Examples:
+    # url(r'^$', 'hello.views.home', name='home'),
+    # url(r'^hello/', include('hello.foo.urls')),
+
+    # Uncomment the admin/doc line below to enable admin documentation:
+    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
+
+    # Uncomment the next line to enable the admin:
+    # url(r'^admin/', include(admin.site.urls)),
+    url(r'^json$', 'world.views.json'),
+    url(r'^db$', 'world.views.db'),
+)

+ 28 - 0
django-optimized/hello/hello/wsgi.py

@@ -0,0 +1,28 @@
+"""
+WSGI config for hello project.
+
+This module contains the WSGI application used by Django's development server
+and any production WSGI deployments. It should expose a module-level variable
+named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
+this application via the ``WSGI_APPLICATION`` setting.
+
+Usually you will have the standard Django WSGI application here, but it also
+might make sense to replace the whole Django WSGI application with a custom one
+that later delegates to the Django one. For example, you could introduce WSGI
+middleware here, or combine a Django application with an application of another
+framework.
+
+"""
+import os
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hello.settings")
+
+# This application object is used by any WSGI server configured to use this
+# file. This includes Django's development server, if the WSGI_APPLICATION
+# setting points here.
+from django.core.wsgi import get_wsgi_application
+application = get_wsgi_application()
+
+# Apply WSGI middleware here.
+# from helloworld.wsgi import HelloWorldApplication
+# application = HelloWorldApplication(application)

+ 10 - 0
django-optimized/hello/manage.py

@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+import os
+import sys
+
+if __name__ == "__main__":
+    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hello.settings")
+
+    from django.core.management import execute_from_command_line
+
+    execute_from_command_line(sys.argv)

+ 11 - 0
django-optimized/hello/templates/base.html

@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+
+<body>
+  <div id="content">
+    {% block content %}{% endblock %}
+  </div>
+</body>
+</html>

+ 0 - 0
django-optimized/hello/world/__init__.py


+ 9 - 0
django-optimized/hello/world/models.py

@@ -0,0 +1,9 @@
+from django.db import models
+
+# Create your models here.
+
+class World(models.Model):
+  randomNumber = models.IntegerField()
+  class Meta:
+    db_table = 'World'
+

+ 25 - 0
django-optimized/hello/world/views.py

@@ -0,0 +1,25 @@
+# Create your views here.
+
+from django.template import Context, loader
+from django.http import HttpResponse
+from django.core import serializers
+from world.models import World
+import simplejson
+import random
+
+def json(request):
+  response = {
+    "message": "Hello, World!"
+  }
+  return HttpResponse(simplejson.dumps(response), mimetype="application/json")
+
+def db(request):
+  queries = int(request.GET.get('queries', 1))
+  worlds  = []
+
+  for i in range(queries):
+    # get a random row, we know the ids are between 1 and 10000
+    worlds.append(World.objects.get(id=random.randint(1, 10000)))
+
+  return HttpResponse(serializers.serialize("json", worlds), mimetype="application/json")
+

+ 23 - 0
django-optimized/setup.py

@@ -0,0 +1,23 @@
+
+import subprocess
+import sys
+import setup_util
+import os
+
+def start(args):
+  setup_util.replace_text("django-optimized/hello/hello/settings.py", "HOST': '.*'", "HOST': '" + args.database_host + "'")
+
+  subprocess.Popen("gunicorn hello.wsgi:application -k gevent -b 0.0.0.0:8080 -w " + str((args.max_threads * 2)) + " --log-level=critical", shell=True, cwd="django-optimized/hello")
+  return 0
+def stop():
+  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
+  out, err = p.communicate()
+  for line in out.splitlines():
+    if 'gunicorn' in line:
+      try:
+        pid = int(line.split(None, 2)[1])
+        os.kill(pid, 9)
+      except OSError:
+        pass
+
+  return 0

+ 2 - 4
django/setup.py

@@ -1,4 +1,3 @@
-
 import subprocess
 import sys
 import setup_util
@@ -6,8 +5,7 @@ import os
 
 def start(args):
   setup_util.replace_text("django/hello/hello/settings.py", "HOST': '.*'", "HOST': '" + args.database_host + "'")
-
-  subprocess.Popen("gunicorn hello.wsgi:application -b 0.0.0.0:8080 -w " + str((args.max_threads * 2)) + " --log-level=critical", shell=True, cwd="django/hello")
+  subprocess.Popen("gunicorn hello.wsgi:application -k gevent  -b 0.0.0.0:8080 -w " + str((args.max_threads * 2)) + " --log-level=critical", shell=True, cwd="django/hello")
   return 0
 def stop():
   p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
@@ -20,4 +18,4 @@ def stop():
       except OSError:
         pass
 
-  return 0
+  return 0

+ 17 - 0
flask/README.md

@@ -0,0 +1,17 @@
+# Flask Benchmark Test
+
+Single file test, [app.py](app.py)
+
+
+## Test URLs
+### JSON Encoding 
+
+http://localhost:8080/json
+
+### Single Row Random Query
+
+http://localhost:8080/db
+
+### Variable Row Query Test
+
+http://localhost:8080/db?queries=2

+ 0 - 0
flask/__init__.py


+ 38 - 0
flask/app.py

@@ -0,0 +1,38 @@
+from flask import Flask, jsonify, request
+from flask.ext.sqlalchemy import SQLAlchemy
+from random import randint
+
+app = Flask(__name__)
+app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://benchmarkdbuser:benchmarkdbpass@DBHOSTNAME:3306/hello_world'
+db = SQLAlchemy(app)
+
+class World(db.Model):
+  __tablename__ = "World"
+  id = db.Column(db.Integer, primary_key=True)
+  randomNumber = db.Column(db.Integer)
+  
+  # http://stackoverflow.com/questions/7102754/jsonify-a-sqlalchemy-result-set-in-flask
+  @property
+  def serialize(self):
+     """Return object data in easily serializeable format"""
+     return {
+         'id'         : self.id,
+         'randomNumber': self.randomNumber
+     }
+
[email protected]("/json")
+def hello():
+  resp = {"message": "Hello, World!"}
+  return jsonify(resp)
+
[email protected]("/db")
+def get_random_world():
+  num_queries = request.args.get("queries", 1)
+  worlds = []
+  for i in range(int(num_queries)):
+    wid = randint(1, 10000)
+    worlds.append(World.query.get(wid).serialize)
+  return jsonify(worlds=worlds)
+  
+if __name__ == "__main__":
+    app.run()

+ 13 - 0
flask/benchmark_config

@@ -0,0 +1,13 @@
+{
+  "framework": "flask",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/json",
+      "db_url": "/db",
+      "query_url": "/db?queries=",
+      "port": 8080,
+      "sort": 31
+    }
+  }]
+}

+ 23 - 0
flask/setup.py

@@ -0,0 +1,23 @@
+import subprocess
+import sys
+import setup_util
+import os
+
+def start(args):
+  setup_util.replace_text("flask/app.py", "DBHOSTNAME", args.database_host)
+  subprocess.Popen("gunicorn app:app -b 0.0.0.0:8080 -w " + str((args.max_threads * 2)) + " --log-level=critical", shell=True, cwd="flask")
+  
+  return 0
+
+def stop():
+  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
+  out, err = p.communicate()
+  for line in out.splitlines():
+    if 'gunicorn' in line:
+      try:
+        pid = int(line.split(None, 2)[1])
+        os.kill(pid, 9)
+      except OSError:
+        pass
+  
+  return 0

+ 17 - 2
installer.py

@@ -100,13 +100,22 @@ class Installer:
     self.__run_command("sudo mv /etc/apache2/ports.conf /etc/apache2/ports.conf.orig")
     self.__run_command("sudo sh -c \"cat ../config/ports.conf > /etc/apache2/ports.conf\"")
     self.__run_command("sudo /etc/init.d/apache2 stop")
-
+    
+    #
+    # Nginx
+    #
+    self.__run_command("curl http://nginx.org/download/nginx-1.2.7.tar.gz | tar xvz")
+    self.__run_command("./configure", cwd="nginx-1.2.7")
+    self.__run_command("make", cwd="nginx-1.2.7")
+    self.__run_command("sudo make install", cwd="nginx-1.2.7")
+    
     #
     # Gunicorn
     #
 
     self.__run_command("sudo easy_install -U 'gunicorn==0.17.2'")
     self.__run_command("sudo easy_install -U 'eventlet==0.12.1'")
+    self.__run_command("sudo pip install --upgrade 'gevent==0.13.8'")
 
     #
     # Resin
@@ -177,6 +186,12 @@ class Installer:
     self.__run_command("wget http://dist.springframework.org.s3.amazonaws.com/release/GRAILS/grails-2.1.1.zip")
     self.__run_command("unzip -o grails-2.1.1.zip")
     self.__run_command("rm grails-2.1.1.zip")
+    
+
+    ##############################
+    # Flask
+    ##############################
+    self.__run_command("sudo pip install flask flask-sqlalchemy")
 
     ##############################
     # Play
@@ -305,4 +320,4 @@ class Installer:
       pass
   ############################################################
   # End __init__
-  ############################################################
+  ############################################################

+ 0 - 1
play-java/README.md

@@ -15,7 +15,6 @@ This is the Play portion of a [benchmarking test suite](../) comparing a variety
 The tests were run with:
 
 * [Java OpenJDK 1.7.0_09](http://openjdk.java.net/)
-* [Resin 4.0.34](http://www.caucho.com/)
 * [Play 2.1.0](http://http://www.playframework.com/)
 
 ## Test URLs

+ 2 - 2
play-java/setup.py

@@ -17,7 +17,7 @@ def stop():
   p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
   out, err = p.communicate()
   for line in out.splitlines():
-    if 'play' in line and 'java' in line:
+    if './start' in line or ('play' in line and 'java' in line):   
       pid = int(line.split(None, 2)[1])
       os.kill(pid, 9)
   try:
@@ -25,4 +25,4 @@ def stop():
   except OSError:
     pass
     
-  return 0
+  return 0

+ 7 - 0
play-scala/.gitignore

@@ -0,0 +1,7 @@
+logs
+project/project
+project/target
+target
+tmp
+.history
+dist

+ 27 - 0
play-scala/README.md

@@ -0,0 +1,27 @@
+#Play Benchmarking Test
+
+This is the Play portion of a [benchmarking test suite](../) comparing a variety of web development platforms.
+
+### JSON Encoding Test
+
+* [JSON test source](app/controllers/Application.java)
+
+### Data-Store/Database Mapping Test
+
+* [Database test controller](app/controllers/Application.scala)
+* [Database test model](app/models/World.java)
+
+## Infrastructure Software Versions
+The tests were run with:
+
+* [Java OpenJDK 1.7.0_09](http://openjdk.java.net/)
+* [Play 2.1.0](http://http://www.playframework.com/)
+
+## Test URLs
+### JSON Encoding Test
+
+http://localhost/json
+
+### Data-Store/Database Mapping Test
+
+http://localhost/db?queries=5

+ 0 - 0
play-scala/__init__.py


+ 40 - 0
play-scala/app/controllers/Application.scala

@@ -0,0 +1,40 @@
+package controllers
+
+import play._
+import play.api.libs.concurrent._
+import play.api.mvc._
+import play.libs.Json
+import org.codehaus.jackson.node.ObjectNode
+import views.html._
+import models._
+import java.util._
+import java.util.concurrent.ThreadLocalRandom
+import scala.concurrent._
+
+object Application extends Controller {
+  private val TEST_DATABASE_ROWS = 10000
+
+  def json() = Action {
+    val result = Json.newObject()
+    result.put("message", "Hello World!")
+    Ok(result.toString)
+  }
+
+  def db(queries: Int) = Action {
+    import play.api.libs.concurrent.Execution.Implicits._
+
+    val random = ThreadLocalRandom.current()
+
+    Async {
+      Future {
+        (1 to queries) map {
+          _ =>
+            World.find.byId(random.nextInt(TEST_DATABASE_ROWS) + 1)
+        }
+      } map {
+        worlds =>
+          Ok(Json.toJson(worlds).toString())
+      }
+    }
+  }
+}

+ 24 - 0
play-scala/app/models/World.java

@@ -0,0 +1,24 @@
+package models;
+
+import java.util.*;
+import javax.persistence.*;
+
+import play.db.ebean.*;
+import play.db.ebean.Model.Finder;
+import play.data.format.*;
+import play.data.validation.*;
+
+@Entity
+public class World extends Model {
+
+  @Id
+  public Long id;
+
+  @Column(name = "randomNumber")
+  public Long randomNumber;
+
+  public static Finder<Long,World> find = new Finder<Long,World>(
+    Long.class, World.class
+  );
+
+}

+ 11 - 0
play-scala/benchmark_config

@@ -0,0 +1,11 @@
+{
+  "framework": "play-scala",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/json",
+      "port": 9000,
+      "sort": 32
+    }
+  }]
+}

+ 74 - 0
play-scala/conf/application.conf

@@ -0,0 +1,74 @@
+# This is the main configuration file for the application.
+# ~~~~~
+
+# Secret key
+# ~~~~~
+# The secret key is used to secure cryptographics functions.
+# If you deploy your application to several instances be sure to use the same key!
+application.secret="RItx1I:80?W@]8GAtPDuF8Ydd3mXM85p/<7og]Q;uBOdijQAauRDgu73B6`wQP59"
+
+# The application languages
+# ~~~~~
+application.langs="en"
+
+# Global object class
+# ~~~~~
+# Define the Global object class for this application.
+# Default to Global in the root package.
+# global=Global
+
+# Database configuration
+# ~~~~~ 
+# You can declare as many datasources as you want.
+# By convention, the default datasource is named `default`
+#
+# db.default.driver=org.h2.Driver
+# db.default.url="jdbc:h2:mem:play"
+# db.default.user=sa
+# db.default.password=
+#
+# You can expose this datasource via JNDI if needed (Useful for JPA)
+# db.default.jndiName=DefaultDS
+db.default.driver= com.mysql.jdbc.Driver
+db.default.url="jdbc:mysql://localhost:3306/hello_world"
+db.default.user=benchmarkdbuser
+db.default.password=benchmarkdbpass
+db.default.jndiName=DefaultDS
+
+db.default.partitionCount=2
+
+# The number of connections to create per partition. Setting this to 
+# 5 with 3 partitions means you will have 15 unique connections to the 
+# database. Note that BoneCP will not create all these connections in 
+# one go but rather start off with minConnectionsPerPartition and 
+# gradually increase connections as required.
+db.default.maxConnectionsPerPartition=5
+
+# The number of initial connections, per partition.
+db.default.minConnectionsPerPartition=5
+
+# Evolutions
+# ~~~~~
+# You can disable evolutions if needed
+# evolutionplugin=disabled
+
+# Ebean configuration
+# ~~~~~
+# You can declare as many Ebean servers as you want.
+# By convention, the default server is named `default`
+#
+ebean.default="models.*"
+
+# Logger
+# ~~~~~
+# You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory .
+
+# Root logger:
+logger.root=ERROR
+
+# Logger used by the framework:
+logger.play=ERROR
+
+# Logger provided to your application:
+logger.application=ERROR
+

+ 10 - 0
play-scala/conf/routes

@@ -0,0 +1,10 @@
+# Routes
+# This file defines all application routes (Higher priority routes first)
+# ~~~~
+
+# Home page
+GET     /json                           controllers.Application.json
+GET     /db                             controllers.Application.db(queries: Int ?= 1)
+
+# Map static resources from the /public folder to the /assets URL path
+GET     /assets/*file               controllers.Assets.at(path="/public", file)

+ 23 - 0
play-scala/project/Build.scala

@@ -0,0 +1,23 @@
+import sbt._
+import Keys._
+import PlayProject._
+
+object ApplicationBuild extends Build {
+
+    val appName         = "play-scala"
+    val appVersion      = "1.0-SNAPSHOT"
+
+    val appDependencies = Seq(
+      // Add your project dependencies here,
+      javaCore,
+      javaJdbc,
+      javaEbean,
+      "mysql" % "mysql-connector-java" % "5.1.22"
+
+    )
+
+    val main = play.Project(appName, appVersion, appDependencies).settings(
+      // Add your own project settings here
+    )
+
+}

+ 1 - 0
play-scala/project/build.properties

@@ -0,0 +1 @@
+sbt.version=0.12.2

+ 8 - 0
play-scala/project/plugins.sbt

@@ -0,0 +1,8 @@
+// Comment to get more information during initialization
+logLevel := Level.Warn
+
+// The Typesafe repository 
+resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
+
+// Use the Play sbt plugin for Play projects
+addSbtPlugin("play" % "sbt-plugin" % "2.1.0")

+ 28 - 0
play-scala/setup.py

@@ -0,0 +1,28 @@
+
+import subprocess
+import sys
+import setup_util
+import os
+
+def start(args):
+  setup_util.replace_text("play-scala/conf/application.conf", "jdbc:mysql:\/\/.*:3306", "jdbc:mysql://" + args.database_host + ":3306")
+
+  subprocess.check_call("play dist", shell=True, cwd="play-scala")
+  subprocess.check_call("unzip play-scala-1.0-SNAPSHOT.zip", shell=True, cwd="play-scala/dist")
+  subprocess.check_call("chmod +x start", shell=True, cwd="play-scala/dist/play-scala-1.0-SNAPSHOT")
+  subprocess.Popen("./start", shell=True, cwd="play-scala/dist/play-scala-1.0-SNAPSHOT")
+
+  return 0
+def stop():
+  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
+  out, err = p.communicate()
+  for line in out.splitlines():
+    if './start' in line or ('play' in line and 'java' in line):
+      pid = int(line.split(None, 2)[1])
+      os.kill(pid, 9)
+  try:
+    os.remove("play-scala/RUNNING_PID")
+  except OSError:
+    pass
+
+  return 0

+ 8 - 16
spring/src/main/java/hello/web/HelloDbController.java

@@ -19,18 +19,20 @@ import org.springframework.stereotype.*;
 import org.springframework.web.bind.annotation.*;
 
 @Controller
-public class HelloDbController 
+public class HelloDbController
 {
+
   private static final int    DB_ROWS                = 10000;
 
-  @RequestMapping(value = "/db")
-  public Object index(HttpServletRequest request, HttpServletResponse response, Integer queries)
+  @RequestMapping(value = "/db", produces = "application/json")
+  @ResponseBody
+  public World[] index(Integer queries)
   {
     if (queries == null)
     {
       queries = 1;
     }
-    
+
     final World[] worlds = new World[queries];
     final Random random = ThreadLocalRandom.current();
     final Session session = HibernateUtil.getSessionFactory().openSession();
@@ -41,17 +43,7 @@ public class HelloDbController
     }
 
     session.close();
-    
-    try 
-    {
-      new MappingJackson2HttpMessageConverter().write(
-          worlds, MediaType.APPLICATION_JSON, new ServletServerHttpResponse(response));
-    } 
-    catch (IOException e) 
-    {
-      // do nothing
-    }
-    
-    return null;
+
+    return worlds;
   }
 }

+ 25 - 16
spring/src/main/java/hello/web/HelloJsonController.java

@@ -11,27 +11,36 @@ import org.springframework.http.converter.json.*;
 import org.springframework.http.server.*;
 import org.springframework.stereotype.*;
 import org.springframework.web.bind.annotation.*;
- 
+
 /**
  * Handles requests for the application home page.
  */
 @Controller
-public class HelloJsonController {
- 
-  @RequestMapping(value = "/json")
-  public Object json(HttpServletResponse response) 
+public class HelloJsonController
+{
+
+  @RequestMapping(value = "/json", produces = "application/json")
+  @ResponseBody
+  public Message json()
+  {
+    return new Message("Hello, world");
+  }
+
+  public static class Message
   {
-    Map<String, String> json = new HashMap<String, String>();
-    json.put("message", "Hello, world");
-
-    try {
-      new MappingJackson2HttpMessageConverter().write(
-          json, MediaType.APPLICATION_JSON, new ServletServerHttpResponse(response));
-    } catch (HttpMessageNotWritableException e) {
-        e.printStackTrace();
-    } catch (IOException e) {
-        e.printStackTrace();
+
+    private final String message;
+
+    public Message(String message)
+    {
+      this.message = message;
+    }
+
+    public String getMessage()
+    {
+      return message;
     }
-    return null;
+
   }
+
 }

+ 3 - 3
spring/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml

@@ -4,9 +4,9 @@
     xmlns:mvc="http://www.springframework.org/schema/mvc"
     xmlns:context="http://www.springframework.org/schema/context"
     xsi:schemaLocation="
-        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
-        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
-        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
+        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
+        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
 
     <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
  

+ 6 - 0
tapestry/hello/.gitignore

@@ -1 +1,7 @@
 target
+build
+.gradle
+*.iml
+*.ipr
+*.iws
+

+ 5 - 10
tapestry/hello/build.gradle

@@ -3,6 +3,7 @@ description = "hello application"
 apply plugin: "war"
 apply plugin: "java"
 apply plugin: "jetty"
+apply plugin: "idea"
 
 sourceCompatibility = "1.5"
 targetCompatibility = "1.5"
@@ -15,15 +16,6 @@ repositories {
 
     // All things JBoss/Hibernate
     mavenRepo name: "JBoss", url: "http://repository.jboss.org/nexus/content/groups/public/"
-
-    // For stable versions of the tapx libraries
-    mavenRepo name: "HLS", url: "http://howardlewisship.com/repository/"
-
-    // For non-stable versions of the tapx libraries
-    mavenRepo name: "HLS Snapshots", url: "http://howardlewisship.com/snapshot-repository/"
-
-    // For access to Apache Staging (Preview) packages
-    mavenRepo name: "Apache Staging", url: "https://repository.apache.org/content/groups/staging"
 }
 
 // This simulates Maven's "provided" scope, until it is officially supported by Gradle
@@ -45,7 +37,10 @@ sourceSets {
 
 dependencies {
 
-    compile "org.apache.tapestry:tapestry-core:5.3.6"
+    compile "mysql:mysql-connector-java:5.1.19"
+    compile "org.hibernate:hibernate-core:3.6.3.Final"
+    compile "org.apache.tapestry:tapestry-hibernate:5.3.6"
+    compile "com.fasterxml.jackson.core:jackson-databind:2.1.4"
 
     // This adds automatic compression of JavaScript and CSS in production mode:
     compile "org.apache.tapestry:tapestry-yuicompressor:5.3.6"

+ 1 - 73
tapestry/hello/src/main/java/hello/services/AppModule.java

@@ -1,17 +1,8 @@
 package hello.services;
 
-import java.io.IOException;
-
-import org.apache.tapestry5.*;
+import org.apache.tapestry5.SymbolConstants;
 import org.apache.tapestry5.ioc.MappedConfiguration;
-import org.apache.tapestry5.ioc.OrderedConfiguration;
 import org.apache.tapestry5.ioc.ServiceBinder;
-import org.apache.tapestry5.ioc.annotations.Local;
-import org.apache.tapestry5.services.Request;
-import org.apache.tapestry5.services.RequestFilter;
-import org.apache.tapestry5.services.RequestHandler;
-import org.apache.tapestry5.services.Response;
-import org.slf4j.Logger;
 
 /**
  * This module is automatically included as part of the Tapestry IoC Registry, it's a good place to
@@ -51,67 +42,4 @@ public class AppModule
         // the first locale name is the default when there's no reasonable match).
         configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en");
     }
-
-
-    /**
-     * This is a service definition, the service will be named "TimingFilter". The interface,
-     * RequestFilter, is used within the RequestHandler service pipeline, which is built from the
-     * RequestHandler service configuration. Tapestry IoC is responsible for passing in an
-     * appropriate Logger instance. Requests for static resources are handled at a higher level, so
-     * this filter will only be invoked for Tapestry related requests.
-     * <p/>
-     * <p/>
-     * Service builder methods are useful when the implementation is inline as an inner class
-     * (as here) or require some other kind of special initialization. In most cases,
-     * use the static bind() method instead.
-     * <p/>
-     * <p/>
-     * If this method was named "build", then the service id would be taken from the
-     * service interface and would be "RequestFilter".  Since Tapestry already defines
-     * a service named "RequestFilter" we use an explicit service id that we can reference
-     * inside the contribution method.
-     */
-    public RequestFilter buildTimingFilter(final Logger log)
-    {
-        return new RequestFilter()
-        {
-            public boolean service(Request request, Response response, RequestHandler handler)
-                    throws IOException
-            {
-                long startTime = System.currentTimeMillis();
-
-                try
-                {
-                    // The responsibility of a filter is to invoke the corresponding method
-                    // in the handler. When you chain multiple filters together, each filter
-                    // received a handler that is a bridge to the next filter.
-
-                    return handler.service(request, response);
-                } finally
-                {
-                    long elapsed = System.currentTimeMillis() - startTime;
-
-                    log.info(String.format("Request time: %d ms", elapsed));
-                }
-            }
-        };
-    }
-
-    /**
-     * This is a contribution to the RequestHandler service configuration. This is how we extend
-     * Tapestry using the timing filter. A common use for this kind of filter is transaction
-     * management or security. The @Local annotation selects the desired service by type, but only
-     * from the same module.  Without @Local, there would be an error due to the other service(s)
-     * that implement RequestFilter (defined in other modules).
-     */
-    public void contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration,
-                                         @Local
-                                         RequestFilter filter)
-    {
-        // Each contribution to an ordered configuration has a name, When necessary, you may
-        // set constraints to precisely control the invocation order of the contributed filter
-        // within the pipeline.
-
-        configuration.add("Timing", filter);
-    }
 }