forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
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
- Loading branch information
Showing
31 changed files
with
942 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-vertx-http-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-infinispan-client-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> |
23 changes: 23 additions & 0 deletions
23
...ain/java/io/quarkus/infinispan/sessions/deployment/InfinispanSessionsBuildTimeConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.quarkus.infinispan.sessions.deployment; | ||
|
||
import java.util.Optional; | ||
|
||
import io.quarkus.runtime.annotations.ConfigItem; | ||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
|
||
/** | ||
* Configuration of Vert.x Web sessions stored in remote Infinispan cache. | ||
*/ | ||
@ConfigRoot(name = "http.sessions.infinispan", phase = ConfigPhase.BUILD_TIME) | ||
public class InfinispanSessionsBuildTimeConfig { | ||
/** | ||
* Name of the Infinispan client configured in the Quarkus Infinispan Client extension configuration. | ||
* If not set, uses the default (unnamed) Infinispan client. | ||
* <p> | ||
* Note that the Infinispan client must be configured to so that the user has necessary permissions | ||
* on the Infinispan server. The required minimum is the Infinispan {@code deployer} role. | ||
*/ | ||
@ConfigItem | ||
public Optional<String> clientName; | ||
} |
46 changes: 46 additions & 0 deletions
46
.../src/main/java/io/quarkus/infinispan/sessions/deployment/InfinispanSessionsProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
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.spi.InfinispanConstants; | ||
import io.quarkus.infinispan.sessions.runtime.InfinispanSessionsRecorder; | ||
import io.quarkus.vertx.http.deployment.SessionStoreProviderBuildItem; | ||
import io.quarkus.vertx.http.runtime.HttpBuildTimeConfig; | ||
import io.quarkus.vertx.http.runtime.SessionsBuildTimeConfig; | ||
|
||
public class InfinispanSessionsProcessor { | ||
@BuildStep | ||
public void infinispanClients(HttpBuildTimeConfig httpConfig, | ||
InfinispanSessionsBuildTimeConfig config, | ||
BuildProducer<InfinispanClientNameBuildItem> infinispanRequest) { | ||
if (httpConfig.sessions.mode == SessionsBuildTimeConfig.SessionsMode.INFINISPAN) { | ||
String clientName = config.clientName.orElse(InfinispanConstants.DEFAULT_INFINISPAN_CLIENT_NAME); | ||
infinispanRequest.produce(new InfinispanClientNameBuildItem(clientName)); | ||
} | ||
} | ||
|
||
@BuildStep | ||
@Record(ExecutionTime.RUNTIME_INIT) | ||
public void infinispanSessions(HttpBuildTimeConfig httpConfig, | ||
InfinispanSessionsBuildTimeConfig config, | ||
List<InfinispanClientBuildItem> clients, | ||
BuildProducer<SessionStoreProviderBuildItem> provider, | ||
InfinispanSessionsRecorder recorder) { | ||
if (httpConfig.sessions.mode == SessionsBuildTimeConfig.SessionsMode.INFINISPAN) { | ||
String clientName = config.clientName.orElse(InfinispanConstants.DEFAULT_INFINISPAN_CLIENT_NAME); | ||
for (InfinispanClientBuildItem infinispanClient : clients) { | ||
if (clientName.equals(infinispanClient.getName())) { | ||
provider.produce(new SessionStoreProviderBuildItem(recorder.create(infinispanClient.getClient()))); | ||
return; | ||
} | ||
} | ||
throw new IllegalStateException("Unknown Infinispan client: " + clientName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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</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> |
28 changes: 28 additions & 0 deletions
28
...untime/src/main/java/io/quarkus/infinispan/sessions/runtime/InfinispanSessionsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.quarkus.infinispan.sessions.runtime; | ||
|
||
import java.time.Duration; | ||
|
||
import io.quarkus.runtime.annotations.ConfigItem; | ||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
|
||
/** | ||
* Configuration of Vert.x Web sessions stored in remote Infinispan cache. | ||
*/ | ||
@ConfigRoot(name = "http.sessions.infinispan", phase = ConfigPhase.RUN_TIME) | ||
public class InfinispanSessionsConfig { | ||
/** | ||
* Name of the Infinispan cache used to store session data. If it does not exist, it is created | ||
* automatically from Infinispan's default template {@code DIST_SYNC}. | ||
*/ | ||
@ConfigItem(defaultValue = "quarkus.sessions") | ||
public String cacheName; | ||
|
||
/** | ||
* Maximum time to retry when retrieving session data from the Infinispan cache. | ||
* The Vert.x session handler retries when the session data are not found, because | ||
* distributing data across an Infinispan cluster may take time. | ||
*/ | ||
@ConfigItem(defaultValue = "5s") | ||
public Duration retryTimeout; | ||
} |
Oops, something went wrong.