Skip to content

Commit

Permalink
WIP Add support for Vert.x Web sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladicek committed Oct 5, 2023
1 parent eddc83e commit 6ef9ce3
Show file tree
Hide file tree
Showing 32 changed files with 1,058 additions and 4 deletions.
25 changes: 25 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,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>
Expand Down Expand Up @@ -1835,6 +1845,11 @@
<artifactId>quarkus-vertx-http</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-sessions-spi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-dev-console-spi</artifactId>
Expand Down Expand Up @@ -5941,6 +5956,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>
Expand All @@ -5952,6 +5972,11 @@
<artifactId>quarkus-redis-client-deployment</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>
Expand Down
3 changes: 3 additions & 0 deletions extensions/infinispan-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
<modules>
<module>deployment</module>
<module>runtime</module>

<module>sessions/deployment</module>
<module>sessions/runtime</module>
</modules>
</project>
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-arc-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client-deployment</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,35 @@
package io.quarkus.infinispan.sessions.deployment;

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.deployment.builditem.FeatureBuildItem;
import io.quarkus.infinispan.client.deployment.InfinispanClientNameBuildItem;
import io.quarkus.infinispan.client.runtime.InfinispanClientUtil;
import io.quarkus.infinispan.sessions.runtime.InfinispanSessionsRecorder;
import io.quarkus.vertx.http.sessions.spi.SessionStoreKind;
import io.quarkus.vertx.http.sessions.spi.SessionStoreRequestBuildItem;
import io.quarkus.vertx.http.sessions.spi.SessionStoreResponseBuildItem;

public class InfinispanSessionsProcessor {
private static final String FEATURE = "infinispan-sessions";

@BuildStep
public FeatureBuildItem featureBuildItem() {
return new FeatureBuildItem(FEATURE);
}

@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
public void infinispanSessions(SessionStoreRequestBuildItem request,
BuildProducer<SessionStoreResponseBuildItem> response,
BuildProducer<InfinispanClientNameBuildItem> infinispanRequest,
InfinispanSessionsRecorder recorder) {
if (request.is(SessionStoreKind.INFINISPAN)) {
response.produce(new SessionStoreResponseBuildItem(recorder.create()));
infinispanRequest.produce(new InfinispanClientNameBuildItem(
request.clientName(InfinispanClientUtil.DEFAULT_INFINISPAN_CLIENT_NAME)));
}
}
}
70 changes: 70 additions & 0 deletions extensions/infinispan-client/sessions/runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?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-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-infinispan-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-sessions-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>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-maven-plugin</artifactId>
</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,47 @@
package io.quarkus.infinispan.sessions.runtime;

import java.lang.annotation.Annotation;
import java.time.Duration;
import java.util.Map;

import io.quarkus.infinispan.client.runtime.InfinispanClientUtil;
import jakarta.enterprise.inject.Default;
import jakarta.enterprise.inject.Instance;

import org.infinispan.client.hotrod.RemoteCacheManager;

import io.quarkus.arc.Arc;
import io.quarkus.infinispan.client.InfinispanClientName;
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() {
return new SessionStoreProvider() {
@Override
public SessionStore create(Vertx vertx, Map<String, Object> config) {
String clientName = (String) config.get("clientName");
String cacheName = (String) config.get("cacheName");
Duration retryTimeout = (Duration) config.get("retryTimeout");
Annotation qualifier = clientName != null
? InfinispanClientName.Literal.of(clientName)
: Default.Literal.INSTANCE;
Instance<RemoteCacheManager> bean = Arc.container().select(RemoteCacheManager.class, qualifier);
if (bean.isResolvable()) {
RemoteCacheManager client = bean.get();
JsonObject options = new JsonObject()
.put("cacheName", cacheName)
.put("retryTimeout", retryTimeout.toMillis());
return InfinispanSessionStore.create(vertx, options, client);
}
throw new IllegalStateException("Unknown Infinispan client: "
+ (clientName != null ? clientName : InfinispanClientUtil.DEFAULT_INFINISPAN_CLIENT_NAME));
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
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: "stable"
3 changes: 3 additions & 0 deletions extensions/redis-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<modules>
<module>deployment</module>
<module>runtime</module>

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


Expand Down
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-arc-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-redis-client-deployment</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,35 @@
package io.quarkus.redis.sessions.deployment;

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.deployment.builditem.FeatureBuildItem;
import io.quarkus.redis.deployment.client.RequestedRedisClientBuildItem;
import io.quarkus.redis.runtime.client.config.RedisConfig;
import io.quarkus.redis.sessions.runtime.RedisSessionsRecorder;
import io.quarkus.vertx.http.sessions.spi.SessionStoreKind;
import io.quarkus.vertx.http.sessions.spi.SessionStoreRequestBuildItem;
import io.quarkus.vertx.http.sessions.spi.SessionStoreResponseBuildItem;

public class RedisSessionsProcessor {
private static final String FEATURE = "redis-sessions";

@BuildStep
public FeatureBuildItem featureBuildItem() {
return new FeatureBuildItem(FEATURE);
}

@BuildStep
@Record(ExecutionTime.RUNTIME_INIT)
public void redisSessions(SessionStoreRequestBuildItem request,
BuildProducer<SessionStoreResponseBuildItem> response,
BuildProducer<RequestedRedisClientBuildItem> redisRequest,
RedisSessionsRecorder recorder) {
if (request.is(SessionStoreKind.REDIS)) {
response.produce(new SessionStoreResponseBuildItem(recorder.create()));
redisRequest.produce(new RequestedRedisClientBuildItem(
request.clientName(RedisConfig.DEFAULT_CLIENT_NAME)));
}
}
}
Loading

0 comments on commit 6ef9ce3

Please sign in to comment.