Skip to content

Commit 846d0ac

Browse files
author
Charles Pretzer
committed
* first commit with basics
0 parents  commit 846d0ac

File tree

14 files changed

+278
-0
lines changed

14 files changed

+278
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
logs/
2+
target/

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controllers/Application.java

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
package controllers;
2+
3+
import com.fasterxml.jackson.databind.node.ObjectNode;
4+
import play.Logger;
5+
import play.data.DynamicForm;
6+
import play.data.Form;
7+
import play.libs.Json;
8+
import play.mvc.Controller;
9+
import play.mvc.Http;
10+
import play.mvc.Result;
11+
12+
public class Application extends Controller {
13+
14+
public Result configure() {
15+
ObjectNode json = Json.newObject();
16+
17+
if (Logger.isInfoEnabled())
18+
Logger.info("configure");
19+
20+
logRequest(request());
21+
22+
return ok(json);
23+
}
24+
25+
public Result activate() {
26+
ObjectNode json = Json.newObject();
27+
28+
if (Logger.isInfoEnabled())
29+
Logger.info("activate");
30+
31+
logRequest(request());
32+
33+
return ok(json);
34+
}
35+
36+
public Result execute() {
37+
ObjectNode json = Json.newObject();
38+
39+
if (Logger.isInfoEnabled())
40+
Logger.info("execute");
41+
42+
logRequest(request());
43+
44+
return ok(json);
45+
}
46+
47+
public Result discover() {
48+
ObjectNode json = Json.newObject();
49+
50+
if (Logger.isInfoEnabled())
51+
Logger.info("discover");
52+
53+
logRequest(request());
54+
55+
return ok(json);
56+
}
57+
58+
public Result configurePost() {
59+
ObjectNode json = Json.newObject();
60+
61+
if (Logger.isInfoEnabled())
62+
Logger.info("configurePost");
63+
64+
logRequest(request());
65+
66+
return ok(json);
67+
}
68+
69+
public Result activatePost() {
70+
ObjectNode json = Json.newObject();
71+
72+
if (Logger.isInfoEnabled())
73+
Logger.info("activatePost");
74+
75+
logRequest(request());
76+
77+
return ok(json);
78+
}
79+
80+
public Result executePost() {
81+
ObjectNode json = Json.newObject();
82+
83+
if (Logger.isInfoEnabled())
84+
Logger.info("executePost");
85+
86+
logRequest(request());
87+
88+
return ok(json);
89+
}
90+
91+
public Result discoverPost() {
92+
ObjectNode json = Json.newObject();
93+
94+
if (Logger.isInfoEnabled())
95+
Logger.info("discoverPost");
96+
97+
logRequest(request());
98+
99+
return ok(json);
100+
}
101+
102+
private void logRequest(Http.Request request) {
103+
if(Logger.isInfoEnabled()) {
104+
StringBuilder requestString = new StringBuilder("Request:")
105+
.append("\n")
106+
.append("\tbody [")
107+
.append(request().body())
108+
.append("]\n")
109+
.append("\tparameters [");
110+
DynamicForm form = Form.form().bindFromRequest();
111+
112+
if(form != null) {
113+
form.data().forEach((key, value) -> {
114+
requestString.append("\n\tkey: ")
115+
.append(key)
116+
.append(", value: ")
117+
.append(value);
118+
});
119+
}
120+
121+
requestString.append("\n\t]");
122+
123+
Logger.info(requestString.toString());
124+
}
125+
}
126+
127+
}

app/views/index.scala.html

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@(message: String)
2+
3+
@main("Welcome to Play") {
4+
5+
@play20.welcome(message, style = "Java")
6+
7+
}

app/views/main.scala.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@(title: String)(content: Html)
2+
3+
<!DOCTYPE html>
4+
5+
<html lang="en">
6+
<head>
7+
<title>@title</title>
8+
</head>
9+
<body>
10+
@content
11+
</body>
12+
</html>

build.sbt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name := """fr8-java"""
2+
3+
version := "1.0-SNAPSHOT"
4+
5+
lazy val root = (project in file(".")).enablePlugins(PlayJava)
6+
7+
scalaVersion := "2.11.6"
8+
9+
libraryDependencies ++= Seq(
10+
javaJdbc,
11+
cache,
12+
javaWs
13+
)
14+
15+
// Play provides two styles of routers, one expects its actions to be injected, the
16+
// other, legacy style, accesses its actions statically.
17+
routesGenerator := InjectedRoutesGenerator

conf/application.conf

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This is the main configuration file for the application.
2+
# ~~~~~
3+
4+
# Secret key
5+
# ~~~~~
6+
# The secret key is used to secure cryptographics functions.
7+
#
8+
# This must be changed for production, but we recommend not changing it in this file.
9+
#
10+
# See http://www.playframework.com/documentation/latest/ApplicationSecret for more details.
11+
play.crypto.secret = "changeme"
12+
13+
# The application languages
14+
# ~~~~~
15+
play.i18n.langs = [ "en" ]
16+
17+
# Router
18+
# ~~~~~
19+
# Define the Router object to use for this application.
20+
# This router will be looked up first when the application is starting up,
21+
# so make sure this is the entry point.
22+
# Furthermore, it's assumed your route file is named properly.
23+
# So for an application router like `my.application.Router`,
24+
# you may need to define a router file `conf/my.application.routes`.
25+
# Default to Routes in the root package (and conf/routes)
26+
# play.http.router = my.application.Routes
27+
28+
# Database configuration
29+
# ~~~~~
30+
# You can declare as many datasources as you want.
31+
# By convention, the default datasource is named `default`
32+
#
33+
# db.default.driver=org.h2.Driver
34+
# db.default.url="jdbc:h2:mem:play"
35+
# db.default.username=sa
36+
# db.default.password=""
37+
38+
# Evolutions
39+
# ~~~~~
40+
# You can disable evolutions if needed
41+
# play.evolutions.enabled=false
42+
43+
# You can disable evolutions for a specific datasource if necessary
44+
# play.evolutions.db.default.enabled=false

conf/logback.xml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<configuration>
2+
3+
<conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" />
4+
5+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
6+
<encoder>
7+
<pattern>%coloredLevel - %logger - %message%n%xException</pattern>
8+
</encoder>
9+
</appender>
10+
11+
<!--
12+
The logger name is typically the Java/Scala package name.
13+
This configures the log level to log at for a package and its children packages.
14+
-->
15+
<logger name="play" level="INFO" />
16+
<logger name="application" level="DEBUG" />
17+
18+
<root level="ERROR">
19+
<appender-ref ref="STDOUT" />
20+
</root>
21+
22+
</configuration>

conf/routes

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Routes
2+
# This file defines all application routes (Higher priority routes first)
3+
# ~~~~
4+
5+
GET /configure controllers.Application.configure()
6+
GET /activate controllers.Application.activate()
7+
GET /execute controllers.Application.execute()
8+
GET /discover controllers.Application.discover()
9+
10+
POST /configure controllers.Application.configurePost()
11+
POST /activate controllers.Application.activatePost()
12+
POST /execute controllers.Application.executePost()
13+
POST /discover controllers.Application.discoverPost()

project/build.properties

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#Activator-generated Properties
2+
#Wed Feb 24 20:29:41 PST 2016
3+
template.uuid=b508c9a8-ce44-4f1b-8ab0-11ffc31ae19a
4+
sbt.version=0.13.8

project/plugins.sbt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// The Play plugin
2+
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.6")
3+
4+
// Web plugins
5+
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
6+
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.6")
7+
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3")
8+
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")
9+
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")
10+
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")
11+
12+
// Play enhancer - this automatically generates getters/setters for public fields
13+
// and rewrites accessors of these fields to use the getters/setters. Remove this
14+
// plugin if you prefer not to have this feature, or disable on a per project
15+
// basis using disablePlugins(PlayEnhancer) in your build.sbt
16+
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")
17+
18+
// Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using
19+
// enablePlugins(PlayEbean). Note, uncommenting this line will automatically bring in
20+
// Play enhancer, regardless of whether the line above is commented out or not.
21+
// addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0")

public/images/favicon.png

687 Bytes
Loading

public/javascripts/hello.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if (window.console) {
2+
console.log("Welcome to your Play application's JavaScript!");
3+
}

public/stylesheets/main.css

Whitespace-only changes.

0 commit comments

Comments
 (0)