View packaging still in progress
This commit is contained in:
@@ -73,6 +73,16 @@
|
|||||||
</classpathDependencyExcludes>
|
</classpathDependencyExcludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-maven-plugin</artifactId>
|
||||||
|
<version>${jetty.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<webApp>
|
||||||
|
<contextPath>/api/</contextPath>
|
||||||
|
</webApp>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
@@ -51,7 +51,7 @@ class WebappManager : ServletContextListener, ServletContextAttributeListener, H
|
|||||||
/* ServletContextListener interface */
|
/* ServletContextListener interface */
|
||||||
override fun contextInitialized(sce: ServletContextEvent) {
|
override fun contextInitialized(sce: ServletContextEvent) {
|
||||||
context = sce.servletContext
|
context = sce.servletContext
|
||||||
logger.info("---------- Starting Web Application ----------")
|
logger.info("---------- Starting Pairgoth Server ----------")
|
||||||
context.setAttribute("manager", this)
|
context.setAttribute("manager", this)
|
||||||
webappRoot = context.getRealPath("/")
|
webappRoot = context.getRealPath("/")
|
||||||
try {
|
try {
|
||||||
|
@@ -95,6 +95,20 @@
|
|||||||
<!-- <includePath>${basedir}/src/main/sass/plugins/</includePath> -->
|
<!-- <includePath>${basedir}/src/main/sass/plugins/</includePath> -->
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-maven-plugin</artifactId>
|
||||||
|
<version>${jetty.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<scan>0</scan>
|
||||||
|
<systemProperties>
|
||||||
|
<systemProperty>
|
||||||
|
<name>pairgoth.webapp.url</name>
|
||||||
|
<value>http://localhost:8080</value>
|
||||||
|
</systemProperty>
|
||||||
|
</systemProperties>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
# webapp
|
# webapp
|
||||||
webapp.env = dev
|
env = dev
|
||||||
webapp.url = https://localhost:8080
|
webapp.url = https://localhost:8080
|
||||||
|
api.url = https://localhost:8085
|
||||||
|
|
||||||
# store
|
# store
|
||||||
store = file
|
store = file
|
||||||
|
@@ -10,7 +10,7 @@ import okhttp3.internal.EMPTY_REQUEST
|
|||||||
class ApiTool {
|
class ApiTool {
|
||||||
companion object {
|
companion object {
|
||||||
const val JSON = "application/json"
|
const val JSON = "application/json"
|
||||||
val apiRoot = System.getProperty("pairgoth.webapp.url").let { base ->
|
val apiRoot = System.getProperty("pairgoth.api.url").let { base ->
|
||||||
if (base.endsWith('/')) "${base}api/"
|
if (base.endsWith('/')) "${base}api/"
|
||||||
else "${base}/api/"
|
else "${base}/api/"
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,7 @@ class LanguageFilter : Filter {
|
|||||||
// the request must be redirected
|
// the request must be redirected
|
||||||
val preferredLanguage = getPreferredLanguage(request)
|
val preferredLanguage = getPreferredLanguage(request)
|
||||||
val destination = if (lang != null) target else uri
|
val destination = if (lang != null) target else uri
|
||||||
response.sendRedirect("${preferredLanguage}${destination}")
|
response.sendRedirect("/${preferredLanguage}${destination}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -51,7 +51,7 @@ class WebappManager : ServletContextListener, ServletContextAttributeListener, H
|
|||||||
/* ServletContextListener interface */
|
/* ServletContextListener interface */
|
||||||
override fun contextInitialized(sce: ServletContextEvent) {
|
override fun contextInitialized(sce: ServletContextEvent) {
|
||||||
context = sce.servletContext
|
context = sce.servletContext
|
||||||
logger.info("---------- Starting Web Application ----------")
|
logger.info("---------- Starting Pairgoth Web Client ----------")
|
||||||
context.setAttribute("manager", this)
|
context.setAttribute("manager", this)
|
||||||
webappRoot = context.getRealPath("/")
|
webappRoot = context.getRealPath("/")
|
||||||
try {
|
try {
|
||||||
|
@@ -79,12 +79,25 @@ private fun getResourceProperty(key: String) = serverProps.getProperty(key)?.let
|
|||||||
|
|
||||||
private fun launchServer() {
|
private fun launchServer() {
|
||||||
|
|
||||||
// create webapps contexts
|
// read default properties and provided ones, if any
|
||||||
val apiContext = createContext("api", "/api")
|
readProperties()
|
||||||
val viewContext = createContext("view", "/")
|
|
||||||
|
|
||||||
// handle properties
|
// create webapps contexts
|
||||||
readProperties(apiContext, viewContext)
|
val webAppContexts = mutableListOf<WebAppContext>()
|
||||||
|
val mode = serverProps["mode"] ?: throw Error("missing property: mode")
|
||||||
|
if (mode == "server" || mode == "standalone") webAppContexts.add(createContext("api", "/api"))
|
||||||
|
if (mode == "client" || mode == "standalone") webAppContexts.add(createContext("view", "/"))
|
||||||
|
|
||||||
|
// special handling for logger properties
|
||||||
|
serverProps.stringPropertyNames().asSequence().filter { propName ->
|
||||||
|
propName.startsWith("logger.")
|
||||||
|
}.forEach { propName ->
|
||||||
|
val key = "webapp-slf4j-logger.${propName.substring(7)}"
|
||||||
|
val value = serverProps.getProperty(propName)
|
||||||
|
webAppContexts.forEach { context ->
|
||||||
|
context.setInitParameter(key, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val webappUrl = serverProps.getProperty("webapp.url")?.let { URL(it) } ?: throw Error("missing property webapp.url")
|
val webappUrl = serverProps.getProperty("webapp.url")?.let { URL(it) } ?: throw Error("missing property webapp.url")
|
||||||
val secure = webappUrl.protocol == "https"
|
val secure = webappUrl.protocol == "https"
|
||||||
@@ -96,7 +109,7 @@ private fun launchServer() {
|
|||||||
|
|
||||||
server.apply {
|
server.apply {
|
||||||
// register webapps
|
// register webapps
|
||||||
handler = ContextHandlerCollection(apiContext, viewContext)
|
handler = ContextHandlerCollection(*webAppContexts.toTypedArray())
|
||||||
if (secure) {
|
if (secure) {
|
||||||
val connector = buildSecureConnector(server, webappUrl.port)
|
val connector = buildSecureConnector(server, webappUrl.port)
|
||||||
addConnector(connector)
|
addConnector(connector)
|
||||||
@@ -112,7 +125,7 @@ private fun createContext(webapp: String, contextPath: String) = WebAppContext()
|
|||||||
context.contextPath = contextPath
|
context.contextPath = contextPath
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun readProperties(vararg contexts: WebAppContext) {
|
private fun readProperties() {
|
||||||
val defaultProps = getResource("/server.default.properties") ?: throw Error("missing default server properties")
|
val defaultProps = getResource("/server.default.properties") ?: throw Error("missing default server properties")
|
||||||
defaultProps.openStream().use {
|
defaultProps.openStream().use {
|
||||||
serverProps.load(InputStreamReader(it, StandardCharsets.UTF_8))
|
serverProps.load(InputStreamReader(it, StandardCharsets.UTF_8))
|
||||||
@@ -123,13 +136,7 @@ private fun readProperties(vararg contexts: WebAppContext) {
|
|||||||
serverProps.entries.forEach { entry ->
|
serverProps.entries.forEach { entry ->
|
||||||
val property = entry.key as String
|
val property = entry.key as String
|
||||||
val value = entry.value as String
|
val value = entry.value as String
|
||||||
if (property.startsWith("logger.")) {
|
if (!property.startsWith("webapp.ssl.")) {
|
||||||
// special handling for logger properties
|
|
||||||
val webappLoggerPropKey = "webapp-slf4j-logger.${property.substring(7)}"
|
|
||||||
contexts.forEach { context ->
|
|
||||||
context.setInitParameter(webappLoggerPropKey, value)
|
|
||||||
}
|
|
||||||
} else if (property.startsWith("webapp.ssl.")) {
|
|
||||||
// do not propagate ssl properties further
|
// do not propagate ssl properties further
|
||||||
} else {
|
} else {
|
||||||
System.setProperty("pairgoth.$property", value)
|
System.setProperty("pairgoth.$property", value)
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
webapp.url = https://localhost:8443
|
webapp.url = https://localhost:8443
|
||||||
webapp.ssl.key = jar:file:$jar!/ssl/localhost.key
|
webapp.ssl.key = jar:file:$jar!/ssl/localhost.key
|
||||||
# webapp.ssl.pass = foobar (not supported for now)
|
webapp.ssl.pass =
|
||||||
webapp.ssl.cert = jar:file:$jar!/ssl/localhost.crt
|
webapp.ssl.cert = jar:file:$jar!/ssl/localhost.crt
|
||||||
|
mode = standalone
|
||||||
|
Reference in New Issue
Block a user