Merge branch 'master' of http://gitlab.jeudego.org/tournois/pairgoth
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,3 +5,4 @@ target
|
|||||||
/pairgoth.properties
|
/pairgoth.properties
|
||||||
*.err
|
*.err
|
||||||
/tournamentfiles
|
/tournamentfiles
|
||||||
|
*.iml
|
@@ -16,7 +16,7 @@
|
|||||||
├── docker .................................... Docker packaging
|
├── docker .................................... Docker packaging
|
||||||
│ ├── pairgoth.properties.example ........... Docker property file to instanciate
|
│ ├── pairgoth.properties.example ........... Docker property file to instanciate
|
||||||
│ └── run.sh ................................ Docker launch script
|
│ └── run.sh ................................ Docker launch script
|
||||||
└── webapp .................................... Engine web application
|
└── api-webapp ................................ Engine web application
|
||||||
└── src
|
└── src
|
||||||
├── main
|
├── main
|
||||||
│ ├── kotlin ........................ Engine kotlin sources (the real meat is here!)
|
│ ├── kotlin ........................ Engine kotlin sources (the real meat is here!)
|
||||||
@@ -26,10 +26,10 @@
|
|||||||
└── kotlin ........................ Engine webapp API unit tests
|
└── kotlin ........................ Engine webapp API unit tests
|
||||||
```
|
```
|
||||||
|
|
||||||
## Webapp sources structure
|
## API Webapp sources structure
|
||||||
|
|
||||||
```
|
```
|
||||||
webapp/src/main/kotlin/org/jeudego/pairgoth
|
api-webapp/src/main/kotlin/org/jeudego/pairgoth
|
||||||
├── api .................................... API handlers
|
├── api .................................... API handlers
|
||||||
├── ext .................................... External: import/export features
|
├── ext .................................... External: import/export features
|
||||||
├── model .................................. Domain logic model
|
├── model .................................. Domain logic model
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
<artifactId>engine-parent</artifactId>
|
<artifactId>engine-parent</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>webapp</artifactId>
|
<artifactId>api-webapp</artifactId>
|
||||||
|
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<name>${project.groupId}:${project.artifactId}</name>
|
<name>${project.groupId}:${project.artifactId}</name>
|
||||||
@@ -51,25 +51,6 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-enforcer-plugin</artifactId>
|
<artifactId>maven-enforcer-plugin</artifactId>
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>enforce-properties-file-exists</id>
|
|
||||||
<goals>
|
|
||||||
<goal>enforce</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<rules>
|
|
||||||
<requireFilesExist>
|
|
||||||
<message>Missing pairgoth.properties file</message>
|
|
||||||
<files>
|
|
||||||
<file>${project.parent.basedir}/pairgoth.properties</file>
|
|
||||||
</files>
|
|
||||||
</requireFilesExist>
|
|
||||||
</rules>
|
|
||||||
<fail>true</fail>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
@@ -41,7 +41,7 @@
|
|||||||
<!-- servlet mappings -->
|
<!-- servlet mappings -->
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>api</servlet-name>
|
<servlet-name>api</servlet-name>
|
||||||
<url-pattern>/api/*</url-pattern>
|
<url-pattern>/*</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>sse</servlet-name>
|
<servlet-name>sse</servlet-name>
|
@@ -15,7 +15,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>webapp</artifactId>
|
<artifactId>api-webapp</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>war</type>
|
<type>war</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
<unpack>true</unpack>
|
<unpack>true</unpack>
|
||||||
<useTransitiveDependencies>false</useTransitiveDependencies>
|
<useTransitiveDependencies>false</useTransitiveDependencies>
|
||||||
<includes>
|
<includes>
|
||||||
<include>${project.groupId}:webapp</include>
|
<include>${project.groupId}:api-webapp</include>
|
||||||
<include>${project.groupId}:bootstrap</include>
|
<include>${project.groupId}:bootstrap</include>
|
||||||
</includes>
|
</includes>
|
||||||
</dependencySet>
|
</dependencySet>
|
||||||
|
@@ -25,11 +25,11 @@ import java.io.IOException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
|
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
||||||
import org.eclipse.jetty.util.resource.PathResource;
|
import org.eclipse.jetty.util.resource.PathResource;
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
|
|
||||||
@@ -41,7 +41,8 @@ public class ServerMain
|
|||||||
PROD
|
PROD
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path basePath;
|
private Path apiBasePath = null;
|
||||||
|
private Path viewBasePath = null;
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
@@ -59,15 +60,25 @@ public class ServerMain
|
|||||||
{
|
{
|
||||||
// create server and web context
|
// create server and web context
|
||||||
Server server = new Server(8080);
|
Server server = new Server(8080);
|
||||||
WebAppContext context = new WebAppContext() {
|
|
||||||
|
WebAppContext apiContext = new WebAppContext() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isServerResource(String name, URL url)
|
public boolean isServerResource(String name, URL url)
|
||||||
{
|
{
|
||||||
return super.isServerResource(name, url) || url.getFile().contains("/WEB-INF/jetty-server/");
|
return super.isServerResource(name, url) || url.getFile().contains("/WEB-INF/jetty-server/");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
context.setContextPath("/");
|
apiContext.setContextPath("/api");
|
||||||
|
|
||||||
|
WebAppContext viewContext = new WebAppContext() {
|
||||||
|
@Override
|
||||||
|
public boolean isServerResource(String name, URL url)
|
||||||
|
{
|
||||||
|
return super.isServerResource(name, url) || url.getFile().contains("/WEB-INF/jetty-server/");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
viewContext.setContextPath("/");
|
||||||
|
|
||||||
// pairgoth runtime properties
|
// pairgoth runtime properties
|
||||||
File properties = new File("./pairgoth.properties");
|
File properties = new File("./pairgoth.properties");
|
||||||
if (properties.exists()) {
|
if (properties.exists()) {
|
||||||
@@ -77,7 +88,7 @@ public class ServerMain
|
|||||||
String property = (String)entry.getKey();
|
String property = (String)entry.getKey();
|
||||||
String value = (String)entry.getValue();
|
String value = (String)entry.getValue();
|
||||||
if (property.startsWith("logger.")) {
|
if (property.startsWith("logger.")) {
|
||||||
context.setInitParameter("webapp-slf4j-logger." + property.substring(7), value);
|
apiContext.setInitParameter("webapp-slf4j-logger." + property.substring(7), value);
|
||||||
} else {
|
} else {
|
||||||
System.setProperty("pairgoth." + property, value);
|
System.setProperty("pairgoth." + property, value);
|
||||||
}
|
}
|
||||||
@@ -88,21 +99,29 @@ public class ServerMain
|
|||||||
{
|
{
|
||||||
case PROD:
|
case PROD:
|
||||||
// Configure as WAR
|
// Configure as WAR
|
||||||
context.setWar(basePath.toString());
|
apiContext.setWar(apiBasePath.toString());
|
||||||
|
viewContext.setWar(viewBasePath.toString());
|
||||||
break;
|
break;
|
||||||
case DEV:
|
case DEV:
|
||||||
// Configuring from Development Base
|
// Configuring from Development Base
|
||||||
context.setBaseResource(new PathResource(basePath.resolve("src/main/webapp")));
|
|
||||||
|
apiContext.setBaseResource(new PathResource(apiBasePath.resolve("src/main/webapp")));
|
||||||
// Add webapp compiled classes & resources (copied into place from src/main/resources)
|
// Add webapp compiled classes & resources (copied into place from src/main/resources)
|
||||||
Path classesPath = basePath.resolve("target/webapp/WEB-INF/classes");
|
Path apiClassesPath = apiBasePath.resolve("target/webapp/WEB-INF/classes");
|
||||||
context.setExtraClasspath(classesPath.toAbsolutePath().toString());
|
apiContext.setExtraClasspath(apiClassesPath.toAbsolutePath().toString());
|
||||||
|
|
||||||
|
viewContext.setBaseResource(new PathResource(viewBasePath.resolve("src/main/webapp")));
|
||||||
|
// Add webapp compiled classes & resources (copied into place from src/main/resources)
|
||||||
|
Path viewClassesPath = viewBasePath.resolve("target/webapp/WEB-INF/classes");
|
||||||
|
viewContext.setExtraClasspath(viewClassesPath.toAbsolutePath().toString());
|
||||||
|
|
||||||
server.setDumpAfterStart(true);
|
server.setDumpAfterStart(true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new FileNotFoundException("Unable to configure WebAppContext base resource undefined");
|
throw new FileNotFoundException("Unable to configure WebAppContext base resource undefined");
|
||||||
}
|
}
|
||||||
|
|
||||||
server.setHandler(context);
|
server.setHandler(new ContextHandlerCollection(apiContext, viewContext));
|
||||||
|
|
||||||
server.start();
|
server.start();
|
||||||
server.join();
|
server.join();
|
||||||
@@ -117,16 +136,19 @@ public class ServerMain
|
|||||||
Path warPath = new File(warLocation).toPath().toRealPath();
|
Path warPath = new File(warLocation).toPath().toRealPath();
|
||||||
if (Files.exists(warPath) && Files.isRegularFile(warPath))
|
if (Files.exists(warPath) && Files.isRegularFile(warPath))
|
||||||
{
|
{
|
||||||
this.basePath = warPath;
|
this.apiBasePath = warPath;
|
||||||
|
this.viewBasePath = warPath;
|
||||||
return OperationalMode.PROD;
|
return OperationalMode.PROD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We are in development mode, likely building and testing from an IDE.
|
// We are in development mode, likely building and testing from an IDE.
|
||||||
Path devPath = new File("../webapp").toPath().toRealPath();
|
Path apiDevPath = new File("../api-webapp").toPath().toRealPath();
|
||||||
if (Files.exists(devPath) && Files.isDirectory(devPath))
|
Path viewDevPath = new File("../view-webapp").toPath().toRealPath();
|
||||||
|
if (Files.exists(apiDevPath) && Files.isDirectory(apiDevPath) && Files.exists(viewDevPath) && Files.isDirectory(viewDevPath))
|
||||||
{
|
{
|
||||||
this.basePath = devPath;
|
this.apiBasePath = apiDevPath;
|
||||||
|
this.viewBasePath = viewDevPath;
|
||||||
return OperationalMode.DEV;
|
return OperationalMode.DEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
curl.sh
2
curl.sh
@@ -21,4 +21,4 @@ curl -s --header "Accept: application/json" http://localhost:8080/api/tour/1/par
|
|||||||
echo
|
echo
|
||||||
echo
|
echo
|
||||||
|
|
||||||
curl -s --header "Last-Event-Id: 0" http://localhost:8080/events
|
curl -s --header "Last-Event-Id: 0" http://localhost:8080/api/events
|
||||||
|
3
pom.xml
3
pom.xml
@@ -59,7 +59,8 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>webapp</module>
|
<module>api-webapp</module>
|
||||||
|
<!-- <module>view-webapp</module> in progress -->
|
||||||
<module>container</module>
|
<module>container</module>
|
||||||
<module>bootstrap</module>
|
<module>bootstrap</module>
|
||||||
<module>application</module>
|
<module>application</module>
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
|
||||||
<Configure id="wac" class="org.eclipse.jetty.webapp.WebAppContext">
|
|
||||||
</Configure>
|
|
||||||
|
|
@@ -1,26 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
|
|
||||||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
|
||||||
<Call name="addConnector">
|
|
||||||
<Arg>
|
|
||||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
|
||||||
<Arg name="server">
|
|
||||||
<Ref refid="Server"/>
|
|
||||||
</Arg>
|
|
||||||
<Arg name="factories">
|
|
||||||
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
|
||||||
<Item>
|
|
||||||
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
|
|
||||||
<Arg name="config">
|
|
||||||
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
|
||||||
</New>
|
|
||||||
</Arg>
|
|
||||||
</New>
|
|
||||||
</Item>
|
|
||||||
</Array>
|
|
||||||
</Arg>
|
|
||||||
<Set name="port"><Property name="jetty.http.port" deprecated="jetty.port" default="${jetty.port}"/></Set>
|
|
||||||
</New>
|
|
||||||
</Arg>
|
|
||||||
</Call>
|
|
||||||
</Configure>
|
|
@@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
|
||||||
|
|
||||||
<!-- ============================================================= --><!-- Configure an HTTPS connector. --><!-- This configuration must be used in conjunction with jetty.xml --><!-- and jetty-ssl.xml. --><!-- ============================================================= -->
|
|
||||||
<Configure id="sslConnector" class="org.eclipse.jetty.server.ServerConnector">
|
|
||||||
|
|
||||||
<Call name="addIfAbsentConnectionFactory">
|
|
||||||
<Arg>
|
|
||||||
<New class="org.eclipse.jetty.server.SslConnectionFactory">
|
|
||||||
<Arg name="next">http/1.1</Arg>
|
|
||||||
<Arg name="sslContextFactory"><Ref refid="sslContextFactory"/></Arg>
|
|
||||||
</New>
|
|
||||||
</Arg>
|
|
||||||
</Call>
|
|
||||||
|
|
||||||
<Call name="addConnectionFactory">
|
|
||||||
<Arg>
|
|
||||||
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
|
|
||||||
<Arg name="config"><Ref refid="sslHttpConfig" /></Arg>
|
|
||||||
<Arg name="compliance"><Call class="org.eclipse.jetty.http.HttpCompliance" name="valueOf"><Arg><Property name="jetty.http.compliance" default="RFC7230"/></Arg></Call></Arg>
|
|
||||||
</New>
|
|
||||||
</Arg>
|
|
||||||
</Call>
|
|
||||||
|
|
||||||
</Configure>
|
|
@@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
|
||||||
<Configure id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory$Server">
|
|
||||||
<Set name="TrustAll">true</Set>
|
|
||||||
<Set name="KeyStorePath"><Property name="jetty.base" default="." />/<Property name="jetty.keystore" default="src/test/resources/jetty.keystore"/></Set>
|
|
||||||
<Set name="KeyStorePassword"><Property name="jetty.keystore.password" default="secret"/></Set>
|
|
||||||
<Set name="KeyManagerPassword"><Property name="jetty.keymanager.password" default="secret"/></Set>
|
|
||||||
<Set name="TrustStorePath"><Property name="jetty.base" default="." />/<Property name="jetty.truststore" default="src/test/resources/jetty.keystore"/></Set>
|
|
||||||
<Set name="TrustStorePassword"><Property name="jetty.truststore.password" default="secret"/></Set>
|
|
||||||
<Set name="EndpointIdentificationAlgorithm"></Set>
|
|
||||||
<New id="sslHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
|
||||||
<Arg><Ref refid="httpConfig"/></Arg>
|
|
||||||
<Call name="addCustomizer">
|
|
||||||
<Arg><New class="org.eclipse.jetty.server.SecureRequestCustomizer"/></Arg>
|
|
||||||
</Call>
|
|
||||||
</New>
|
|
||||||
</Configure>
|
|
@@ -1,46 +0,0 @@
|
|||||||
<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
|
||||||
|
|
||||||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
|
||||||
|
|
||||||
<Call name="addConnector">
|
|
||||||
<Arg>
|
|
||||||
<New id="sslConnector" class="org.eclipse.jetty.server.ServerConnector">
|
|
||||||
<Arg name="server"><Ref refid="Server" /></Arg>
|
|
||||||
<Arg name="acceptors" type="int"><Property name="jetty.ssl.acceptors" deprecated="ssl.acceptors" default="-1"/></Arg>
|
|
||||||
<Arg name="selectors" type="int"><Property name="jetty.ssl.selectors" deprecated="ssl.selectors" default="-1"/></Arg>
|
|
||||||
<Arg name="factories">
|
|
||||||
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
|
||||||
</Array>
|
|
||||||
</Arg>
|
|
||||||
|
|
||||||
<Set name="host"><Property name="jetty.ssl.host" deprecated="jetty.host" /></Set>
|
|
||||||
<Set name="port"><Property name="jetty.ssl.port" deprecated="ssl.port" default="${jetty.ssl.port}" /></Set>
|
|
||||||
<Set name="idleTimeout"><Property name="jetty.ssl.idleTimeout" deprecated="ssl.timeout" default="30000"/></Set>
|
|
||||||
<Set name="acceptorPriorityDelta"><Property name="jetty.ssl.acceptorPriorityDelta" deprecated="ssl.acceptorPriorityDelta" default="0"/></Set>
|
|
||||||
<Set name="acceptQueueSize"><Property name="jetty.ssl.acceptQueueSize" deprecated="ssl.acceptQueueSize" default="0"/></Set>
|
|
||||||
<Set name="reuseAddress"><Property name="jetty.ssl.reuseAddress" default="true"/></Set>
|
|
||||||
<Set name="acceptedTcpNoDelay"><Property name="jetty.ssl.acceptedTcpNoDelay" default="true"/></Set>
|
|
||||||
<Set name="acceptedReceiveBufferSize"><Property name="jetty.ssl.acceptedReceiveBufferSize" default="-1"/></Set>
|
|
||||||
<Set name="acceptedSendBufferSize"><Property name="jetty.ssl.acceptedSendBufferSize" default="-1"/></Set>
|
|
||||||
<Get name="SelectorManager">
|
|
||||||
<Set name="connectTimeout"><Property name="jetty.ssl.connectTimeout" default="15000"/></Set>
|
|
||||||
</Get>
|
|
||||||
</New>
|
|
||||||
</Arg>
|
|
||||||
</Call>
|
|
||||||
|
|
||||||
<New id="sslHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
|
||||||
<Arg><Ref refid="httpConfig"/></Arg>
|
|
||||||
<Call name="addCustomizer">
|
|
||||||
<Arg>
|
|
||||||
<New class="org.eclipse.jetty.server.SecureRequestCustomizer">
|
|
||||||
<Arg name="sniRequired" type="boolean"><Property name="jetty.ssl.sniRequired" default="false"/></Arg>
|
|
||||||
<Arg name="sniHostCheck" type="boolean"><Property name="jetty.ssl.sniHostCheck" default="true"/></Arg>
|
|
||||||
<Arg name="stsMaxAgeSeconds" type="int"><Property name="jetty.ssl.stsMaxAgeSeconds" default="-1"/></Arg>
|
|
||||||
<Arg name="stsIncludeSubdomains" type="boolean"><Property name="jetty.ssl.stsIncludeSubdomains" default="false"/></Arg>
|
|
||||||
</New>
|
|
||||||
</Arg>
|
|
||||||
</Call>
|
|
||||||
</New>
|
|
||||||
|
|
||||||
</Configure>
|
|
@@ -1,8 +0,0 @@
|
|||||||
# webapp
|
|
||||||
webapp.env = ${webapp.env}
|
|
||||||
webapp.url = ${webapp.url}
|
|
||||||
|
|
||||||
# smtp
|
|
||||||
|
|
||||||
# Logging
|
|
||||||
logger.level = ${logger.level}
|
|
Reference in New Issue
Block a user