Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions avaje-jex-http2-jetty/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-jex-parent</artifactId>
<version>3.4-RC2</version>
</parent>
<name>avaje-jex-http2-jetty</name>
<artifactId>avaje-jex-http2-jetty</artifactId>
<version>0.1</version>
<properties>
<maven.compiler.release>21</maven.compiler.release>
<jetty.version>11.0.26</jetty.version>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http-spi</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-server</artifactId>
<version>${jetty.version}</version>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jex-ssl</artifactId>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jex-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb-generator</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.avaje.jex.http2.jetty;

import io.avaje.jex.Jex;
import io.avaje.jex.spi.JexPlugin;
import org.eclipse.jetty.http.spi.JettyHttpServerProvider;
import org.eclipse.jetty.http2.api.server.ServerSessionListener;
import org.eclipse.jetty.http2.server.RawHTTP2ServerConnectionFactory;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;

/** A plugin that configures Jex to enable HTTP/2 using Jetty. */
public final class JettyHttp2JexPlugin extends ServerSessionListener.Adapter implements JexPlugin {

private JettyHttp2JexPlugin() {}

/**
* Creates a new instance of the {@code JettyHttp2JexPlugin}.
*
* @return The new plugin instance.
*/
public static JettyHttp2JexPlugin create() {
return new JettyHttp2JexPlugin();
}

@Override
public void apply(Jex jex) {
Server server = new Server();
SslContextFactory.Server ssl = new SslContextFactory.Server();

RawHTTP2ServerConnectionFactory http2 = new RawHTTP2ServerConnectionFactory(this);
http2.setConnectProtocolEnabled(true);

server.addConnector(new ServerConnector(server, ssl, http2));
JettyHttpServerProvider.setServer(server);

jex.config()
.serverProvider(new JettyHttpServerProvider());
}
}
8 changes: 8 additions & 0 deletions avaje-jex-http2-jetty/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module io.avaje.jex.http2.jetty {
requires transitive io.avaje.jex.ssl;
requires transitive org.eclipse.jetty.server;
requires transitive org.eclipse.jetty.http.spi;
requires transitive org.eclipse.jetty.http2.common;
requires transitive org.eclipse.jetty.http2.server;
requires java.base;
}
46 changes: 46 additions & 0 deletions avaje-jex-http2-robaho/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-jex-parent</artifactId>
<version>3.4-RC2</version>
</parent>
<name>avaje-jex-http2-robaho</name>
<artifactId>avaje-jex-http2-robaho</artifactId>
<version>0.1</version>
<properties>
<maven.compiler.release>21</maven.compiler.release>
<robaho.version>1.0.29</robaho.version>
</properties>
<dependencies>
<dependency>
<groupId>io.github.robaho</groupId>
<artifactId>httpserver</artifactId>
<version>${robaho.version}</version>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jex-ssl</artifactId>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jex-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb-generator</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.avaje.jex.http2.robaho;

import io.avaje.jex.Jex;
import io.avaje.jex.spi.JexPlugin;
import robaho.net.httpserver.DefaultHttpServerProvider;

/** A plugin that configures Jex to enable HTTP/2 using Jetty. */
public final class RobahoHttp2JexPlugin implements JexPlugin {

private RobahoHttp2JexPlugin() {}

/**
* Creates a new instance of the {@code RobahoHttp2JexPlugin}.
*
* @return The new plugin instance.
*/
public static RobahoHttp2JexPlugin create() {
return new RobahoHttp2JexPlugin();
}

@Override
public void apply(Jex jex) {
System.setProperty("robaho.net.httpserver.http2OverSSL", "true");
jex.config()
.serverProvider(new DefaultHttpServerProvider());
}
}
5 changes: 5 additions & 0 deletions avaje-jex-http2-robaho/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module io.avaje.jex.http2.robaho {
requires transitive io.avaje.jex.ssl;
requires java.base;
requires robaho.httpserver;
}
51 changes: 51 additions & 0 deletions avaje-jex-http3-jetty/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-jex-parent</artifactId>
<version>3.4-RC2</version>
</parent>
<name>avaje-jex-http3-jetty</name>
<artifactId>avaje-jex-http3-jetty</artifactId>
<version>0.1</version>
<properties>
<maven.compiler.release>21</maven.compiler.release>
<jetty.version>11.0.26</jetty.version>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http-spi</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.http3</groupId>
<artifactId>http3-server</artifactId>
<version>${jetty.version}</version>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jex-ssl</artifactId>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jex-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb-generator</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package io.avaje.jex.http3.jetty;

import io.avaje.applog.AppLog;
import io.avaje.jex.Jex;
import io.avaje.jex.spi.JexPlugin;
import org.eclipse.jetty.http.spi.JettyHttpServerProvider;
import org.eclipse.jetty.http3.api.Session;
import org.eclipse.jetty.http3.server.RawHTTP3ServerConnectionFactory;
import org.eclipse.jetty.quic.server.QuicServerConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.ssl.SslContextFactory;

import java.net.DatagramSocket;
import java.net.SocketAddress;

import static java.lang.System.Logger.Level.*;

/** A plugin that configures Jex to enable HTTP/3 using Jetty. */
public final class JettyHttp3JexPlugin implements JexPlugin, Session.Server.Listener {

private static final System.Logger LOG = AppLog.getLogger(JettyHttp3JexPlugin.class);

private JettyHttp3JexPlugin() {}

/**
* Creates a new instance of the {@code JettyHttp3JexPlugin}.
*
* @return The new plugin instance.
*/
public static JettyHttp3JexPlugin create() {
return new JettyHttp3JexPlugin();
}

@Override
public void apply(Jex jex) {
Server server = new Server();
SslContextFactory.Server ssl = new SslContextFactory.Server();

RawHTTP3ServerConnectionFactory http3 = new RawHTTP3ServerConnectionFactory(this);
http3.getHTTP3Configuration().setStreamIdleTimeout(15000);

server.addConnector(new QuicServerConnector(server, ssl, http3));
JettyHttpServerProvider.setServer(server);

jex.config()
.serverProvider(new JettyHttpServerProvider());
}

@Override
public void onAccept(Session session) {
SocketAddress address = session.getRemoteSocketAddress();
LOG.log(TRACE, "Connection from {0}", address);
}
}
8 changes: 8 additions & 0 deletions avaje-jex-http3-jetty/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module io.avaje.jex.http3.jetty {
requires transitive io.avaje.jex.ssl;
requires transitive org.eclipse.jetty.server;
requires transitive org.eclipse.jetty.http3.common;
requires transitive org.eclipse.jetty.http3.server;
requires transitive org.eclipse.jetty.http.spi;
requires java.base;
}
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@
<module>avaje-jex-static-content</module>
<module>avaje-jex-test</module>
<module>avaje-jex-ssl</module>
<module>avaje-jex-http2-jetty</module>
<module>avaje-jex-http2-robaho</module>
<module>avaje-jex-http3-flupke</module>
<module>avaje-jex-http3-jetty</module>
</modules>

<dependencyManagement>
Expand Down