Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP Add support for Vert.x Web sessions
Browse files Browse the repository at this point in the history
Ladicek committed Oct 11, 2023
1 parent 1390ebb commit e021689
Showing 36 changed files with 1,020 additions and 5 deletions.
30 changes: 30 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
@@ -1223,6 +1223,16 @@
<artifactId>quarkus-infinispan-client-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-sessions</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-sessions-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jaeger</artifactId>
@@ -1840,6 +1850,16 @@
<artifactId>quarkus-vertx-http</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-sessions-deployment-spi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-sessions-runtime-spi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-dev-console-spi</artifactId>
@@ -5946,6 +5966,11 @@
<artifactId>quarkus-redis-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-client-sessions</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-cache</artifactId>
@@ -5962,6 +5987,11 @@
<artifactId>quarkus-redis-client-deployment-spi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-client-sessions-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-cache-deployment</artifactId>
3 changes: 3 additions & 0 deletions extensions/infinispan-client/pom.xml
Original file line number Diff line number Diff line change
@@ -17,5 +17,8 @@
<module>deployment</module>
<module>deployment-spi</module>
<module>runtime</module>

<module>sessions/deployment</module>
<module>sessions/runtime</module>
</modules>
</project>
5 changes: 5 additions & 0 deletions extensions/infinispan-client/runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -143,6 +143,11 @@
<artifactId>quarkus-kubernetes-service-binding</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-sessions</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
52 changes: 52 additions & 0 deletions extensions/infinispan-client/sessions/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-parent</artifactId>
<version>999-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>quarkus-infinispan-client-sessions-deployment</artifactId>

<name>Quarkus - Infinispan Client - Vert.x Web Sessions - Deployment</name>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-sessions</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-deployment-spi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-sessions-deployment-spi</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package io.quarkus.infinispan.sessions.deployment;

import java.util.List;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.infinispan.client.deployment.spi.InfinispanClientBuildItem;
import io.quarkus.infinispan.client.deployment.spi.InfinispanClientNameBuildItem;
import io.quarkus.infinispan.client.runtime.InfinispanClientUtil;
import io.quarkus.infinispan.sessions.runtime.InfinispanSessionsRecorder;
import io.quarkus.vertx.http.sessions.deployment.spi.SessionStoreRequestBuildItem;
import io.quarkus.vertx.http.sessions.deployment.spi.SessionStoreResponseBuildItem;
import io.quarkus.vertx.http.sessions.spi.SessionStoreKind;

public class InfinispanSessionsProcessor {
@BuildStep
public void infinispanClients(SessionStoreRequestBuildItem request,
BuildProducer<InfinispanClientNameBuildItem> infinispanRequest) {
if (request.is(SessionStoreKind.INFINISPAN)) {
String clientName = request.clientName().orElse(InfinispanClientUtil.DEFAULT_INFINISPAN_CLIENT_NAME);
infinispanRequest.produce(new InfinispanClientNameBuildItem(clientName));
}
}

@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
public void infinispanSessions(SessionStoreRequestBuildItem request,
BuildProducer<SessionStoreResponseBuildItem> response,
List<InfinispanClientBuildItem> infinispanClients,
InfinispanSessionsRecorder recorder) {
if (request.is(SessionStoreKind.INFINISPAN)) {
String clientName = request.clientName().orElse(InfinispanClientUtil.DEFAULT_INFINISPAN_CLIENT_NAME);
for (InfinispanClientBuildItem infinispanClient : infinispanClients) {
if (clientName.equals(infinispanClient.getName())) {
response.produce(new SessionStoreResponseBuildItem(recorder.create(infinispanClient.getClient())));
return;
}
}
throw new IllegalStateException("Unknown Infinispan client: " + clientName);
}
}
}
85 changes: 85 additions & 0 deletions extensions/infinispan-client/sessions/runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-parent</artifactId>
<version>999-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>quarkus-infinispan-client-sessions</artifactId>

<name>Quarkus - Infinispan Client - Vert.x Web Sessions - Runtime</name>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-sessions-runtime-spi</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web-sstore-infinispan</artifactId>
<exclusions>
<exclusion>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-client-hotrod</artifactId>
</exclusion>
<exclusion>
<groupId>io.reactivex.rxjava3</groupId>
<artifactId>rxjava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-client-hotrod-jakarta</artifactId>
<exclusions>
<exclusion>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-jboss-marshalling</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.2_spec</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-maven-plugin</artifactId>
<configuration>
<dependencyCondition>
<artifact>io.quarkus:quarkus-vertx-http</artifact>
</dependencyCondition>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.quarkus.infinispan.sessions.runtime;

import java.time.Duration;
import java.util.Map;

import org.infinispan.client.hotrod.RemoteCacheManager;

import io.quarkus.runtime.RuntimeValue;
import io.quarkus.runtime.annotations.Recorder;
import io.quarkus.vertx.http.sessions.spi.SessionStoreProvider;
import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.sstore.SessionStore;
import io.vertx.ext.web.sstore.infinispan.InfinispanSessionStore;

@Recorder
public class InfinispanSessionsRecorder {
public SessionStoreProvider create(RuntimeValue<RemoteCacheManager> client) {
return new SessionStoreProvider() {
@Override
public SessionStore create(Vertx vertx, Map<String, Object> config) {
String cacheName = (String) config.get("cacheName");
Duration retryTimeout = (Duration) config.get("retryTimeout");
JsonObject options = new JsonObject()
.put("cacheName", cacheName)
.put("retryTimeout", retryTimeout.toMillis());
return InfinispanSessionStore.create(vertx, options, client.getValue());
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
artifact: ${project.groupId}:${project.artifactId}:${project.version}
name: "Infinispan Client - Vert.x Web Sessions"
metadata:
keywords:
- "infinispan"
- "vertx"
- "sessions"
guide: "https://quarkus.io/guides/http-reference#vertx-web-sessions"
categories:
- "web"
status: "preview"
unlisted: true
3 changes: 3 additions & 0 deletions extensions/redis-client/pom.xml
Original file line number Diff line number Diff line change
@@ -20,6 +20,9 @@
<module>deployment</module>
<module>deployment-spi</module>
<module>runtime</module>

<module>sessions/deployment</module>
<module>sessions/runtime</module>
</modules>


5 changes: 5 additions & 0 deletions extensions/redis-client/runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -33,6 +33,11 @@
<artifactId>quarkus-smallrye-health</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-client-sessions</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
52 changes: 52 additions & 0 deletions extensions/redis-client/sessions/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-client-parent</artifactId>
<version>999-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>quarkus-redis-client-sessions-deployment</artifactId>

<name>Quarkus - Redis Client - Vert.x Web Sessions - Deployment</name>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-client-sessions</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-client-deployment-spi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-sessions-deployment-spi</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit e021689

Please sign in to comment.