update to netty 4.1.108, add empty settings, add settings loader to server tests

This commit is contained in:
Jörg Prante 2024-04-03 15:15:41 +02:00
parent f7ce68bada
commit 09b30ad7b6
17 changed files with 76 additions and 30 deletions

View file

@ -1,3 +1,3 @@
group = org.xbib
name = net-http
version = 4.4.1
version = 4.4.2

View file

@ -3,6 +3,7 @@ dependencies {
api libs.net.security
testImplementation project(':net-http-client-netty-secure')
testImplementation project(':net-http-netty-boringssl')
testImplementation libs.settings.datastructures.json
testImplementation libs.net.bouncycastle
}

View file

@ -1,11 +1,13 @@
import org.xbib.net.http.server.netty.HttpChannelInitializer;
import org.xbib.net.security.CertificateProvider;
import org.xbib.net.http.server.netty.ServerTransportProvider;
import org.xbib.settings.SettingsLoader;
module org.xbib.net.http.server.netty.secure.test {
requires transitive org.junit.jupiter.api;
requires io.netty.transport;
requires io.netty.common;
requires org.xbib.settings.datastructures;
requires org.xbib.net;
requires org.xbib.net.http;
requires org.xbib.net.http.server;
@ -19,6 +21,7 @@ module org.xbib.net.http.server.netty.secure.test {
requires org.xbib.net.bouncycastle;
exports org.xbib.net.http.server.netty.secure.test;
opens org.xbib.net.http.server.netty.secure.test;
uses SettingsLoader;
uses HttpChannelInitializer;
uses ServerTransportProvider;
uses CertificateProvider;

View file

@ -0,0 +1 @@
org.xbib.settings.datastructures.json.JsonSettingsLoader

View file

@ -3,6 +3,7 @@ dependencies {
api libs.netty.codec.http2
testImplementation project(':net-http-client-netty')
testImplementation project(':net-http-template-groovy')
testImplementation libs.settings.datastructures.json
testImplementation libs.datastructures.json.tiny
}

View file

@ -1,9 +1,14 @@
import org.xbib.net.http.server.netty.HttpChannelInitializer;
import org.xbib.net.http.server.netty.ServerTransportProvider;
import org.xbib.settings.SettingsLoader;
module org.xbib.net.http.server.netty.test {
requires transitive org.junit.jupiter.api;
requires io.netty.transport;
requires io.netty.common;
requires org.xbib.datastructures.api;
requires org.xbib.datastructures.json.tiny;
requires org.xbib.settings.datastructures;
requires org.xbib.net;
requires org.xbib.net.http;
requires org.xbib.net.http.server;
@ -16,4 +21,7 @@ module org.xbib.net.http.server.netty.test {
opens org.xbib.net.http.server.netty.test;
opens org.xbib.net.http.server.netty.test.pipelining;
opens org.xbib.net.http.server.netty.test.simple;
uses SettingsLoader;
uses HttpChannelInitializer;
uses ServerTransportProvider;
}

View file

@ -0,0 +1 @@
org.xbib.settings.datastructures.json.JsonSettingsLoader

View file

@ -1,6 +1,7 @@
dependencies {
api project(':net-http-server-simple')
api libs.net.security
testImplementation libs.settings.datastructures.json
testImplementation libs.net.bouncycastle
}

View file

@ -1,5 +1,8 @@
import org.xbib.settings.SettingsLoader;
module org.xbib.net.http.server.simple.secure.test {
requires transitive org.junit.jupiter.api;
requires org.xbib.settings.datastructures;
requires org.xbib.net;
requires org.xbib.net.http;
requires org.xbib.net.http.server;
@ -9,4 +12,5 @@ module org.xbib.net.http.server.simple.secure.test {
uses org.xbib.net.security.CertificateProvider;
exports org.xbib.net.http.server.simple.secure.test;
opens org.xbib.net.http.server.simple.secure.test;
uses SettingsLoader;
}

View file

@ -1,5 +1,6 @@
dependencies {
api project(':net-http-server')
testImplementation libs.settings.datastructures.json
}
test {

View file

@ -1,9 +1,13 @@
import org.xbib.settings.SettingsLoader;
module org.xbib.net.http.server.simple.test {
requires transitive org.junit.jupiter.api;
requires org.xbib.settings.datastructures;
requires org.xbib.net;
requires org.xbib.net.http;
requires org.xbib.net.http.server;
requires org.xbib.net.http.server.simple;
exports org.xbib.net.http.server.simple.test;
opens org.xbib.net.http.server.simple.test;
uses SettingsLoader;
}

View file

@ -0,0 +1 @@
org.xbib.settings.datastructures.json.JsonSettingsLoader

View file

@ -22,6 +22,12 @@ import org.xbib.settings.Settings;
public interface Application extends SessionListener, Resolver<Path>, Closeable {
String getName();
String getProfile();
Path getHome();
Collection<HttpDomain> getDomains();
Set<HttpAddress> getAddresses();
@ -32,8 +38,6 @@ public interface Application extends SessionListener, Resolver<Path>, Closeable
MimeTypeService getMimeService();
Path getHome();
String getContextPath();
Settings getSettings();

View file

@ -93,6 +93,21 @@ public class BaseApplication implements Application {
applicationModuleList.add(applicationModule);
}
@Override
public String getName() {
return builder.name;
}
@Override
public String getProfile() {
return builder.profile;
}
@Override
public Path getHome() {
return builder.home;
}
@Override
public Locale getLocale() {
return builder.locale;
@ -108,11 +123,6 @@ public class BaseApplication implements Application {
return builder.mimeTypeService;
}
@Override
public Path getHome() {
return builder.home;
}
@Override
public String getContextPath() {
return builder.contextPath;

View file

@ -18,16 +18,16 @@ public class BaseApplicationBuilder implements ApplicationBuilder {
private static final Set<String> DEFAULT_SUFFIXES =
Set.of("css", "js", "ico", "png", "jpg", "jpeg", "gif", "woff2");
private String name;
protected String name;
private String profile;
protected String profile;
protected Path home;
protected ClassLoader classLoader;
protected Settings settings;
protected Path home;
protected String contextPath;
protected String secret;
@ -59,15 +59,19 @@ public class BaseApplicationBuilder implements ApplicationBuilder {
this.profile = profile;
return this;
}
@Override
public BaseApplicationBuilder setHome(Path home) {
this.home = home;
return this;
}
public BaseApplicationBuilder setSettings(Settings settings) {
this.settings = settings;
return this;
}
@Override
public BaseApplicationBuilder setHome(Path home) {
this.home = home;
public BaseApplicationBuilder setClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
return this;
}
@ -128,12 +132,21 @@ public class BaseApplicationBuilder implements ApplicationBuilder {
@Override
public Application build() {
Objects.requireNonNull(httpRouter, "http router must not be null");
if (this.classLoader == null) {
this.classLoader = getClass().getClassLoader();
if (this.name == null) {
this.name = System.getProperty("application.name", "application");
}
if (this.profile == null) {
this.profile = System.getProperty("application.profile", "developer");
}
if (this.home == null) {
this.home = Paths.get(System.getProperty("application.home", "."));
}
if (this.settings == null) {
this.settings = Settings.emptySettings();
}
if (this.classLoader == null) {
this.classLoader = getClass().getClassLoader();
}
if (this.contextPath == null) {
this.contextPath = "/";
}
@ -146,12 +159,6 @@ public class BaseApplicationBuilder implements ApplicationBuilder {
if (this.zoneId == null) {
this.zoneId = ZoneId.systemDefault();
}
if (name == null) {
name = System.getProperty("application.name", "application");
}
if (profile == null) {
profile = System.getProperty("application.profile", "developer");
}
if (this.mimeTypeService == null) {
this.mimeTypeService = new MimeTypeService();
}

View file

@ -215,11 +215,11 @@ public abstract class DefaultMarkupTemplate extends BaseTemplate {
}
public String bootstrapCss() {
return contextPath("webjars/bootstrap/5.2.3/css/bootstrap.min.css");
return contextPath("webjars/bootstrap/5.1.0/css/bootstrap.min.css");
}
public String bootstrapJs() {
return contextPath("webjars/bootstrap/5.2.3/js/bootstrap.min.js");
return contextPath("webjars/bootstrap/5.1.0/js/bootstrap.min.js");
}
public String jqueryJs() {

View file

@ -2,9 +2,9 @@ dependencyResolutionManagement {
versionCatalogs {
libs {
version('gradle', '8.5')
version('groovy', '4.0.16')
version('netty', '4.1.107.Final')
version('netty-tcnative', '2.0.62.Final')
version('groovy', '4.0.20')
version('netty', '4.1.108.Final')
version('netty-tcnative', '2.0.65.Final')
version('datastructures', '5.0.7')
version('net', '4.3.0')
library('netty-codec-http2', 'io.netty', 'netty-codec-http2').versionRef('netty')
@ -18,8 +18,7 @@ dependencyResolutionManagement {
library('jna', 'net.java.dev.jna', 'jna').version('5.14.0')
library('groovy-templates', 'org.apache.groovy', 'groovy-templates').versionRef('groovy')
library('j2html', 'org.xbib', 'j2html').version('2.0.0')
library('htmlflow', 'com.github.xmlet', 'htmlflow').version('4.0')
library('webjars-bootstrap', 'org.webjars', 'bootstrap').version('5.2.3')
library('webjars-bootstrap', 'org.webjars', 'bootstrap').version('5.1.0')
library('webjars-jquery', 'org.webjars', 'jquery').version('3.6.4')
library('webjars-fontawesome', 'org.webjars', 'font-awesome').version('6.3.0')
library('net', 'org.xbib', 'net').versionRef('net')