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.
Merge pull request quarkusio#35817 from geoand/quarkusio#35680
Improve Qute + Cache integration
- Loading branch information
Showing
5 changed files
with
107 additions
and
6 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...ache/deployment-spi/src/main/java/io/quarkus/cache/deployment/spi/CacheTypeBuildItem.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,25 @@ | ||
package io.quarkus.cache.deployment.spi; | ||
|
||
import io.quarkus.builder.item.SimpleBuildItem; | ||
|
||
/** | ||
* A build item that can be used by extensions to determine what kind of cache backend is configured. | ||
* This is useful for cases where caching extensions specific data does not make sense for remote cache backends | ||
*/ | ||
public final class CacheTypeBuildItem extends SimpleBuildItem { | ||
|
||
private final Type type; | ||
|
||
public CacheTypeBuildItem(Type type) { | ||
this.type = type; | ||
} | ||
|
||
public Type getType() { | ||
return type; | ||
} | ||
|
||
public enum Type { | ||
LOCAL, | ||
REMOTE | ||
} | ||
} |
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
31 changes: 25 additions & 6 deletions
31
extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/CacheProcessor.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
24 changes: 24 additions & 0 deletions
24
...ns/qute/runtime/src/main/java/io/quarkus/qute/runtime/cache/MissingCacheConfigurator.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,24 @@ | ||
package io.quarkus.qute.runtime.cache; | ||
|
||
import java.util.concurrent.CompletionStage; | ||
import java.util.function.Function; | ||
|
||
import jakarta.enterprise.event.Observes; | ||
|
||
import io.quarkus.qute.CacheSectionHelper; | ||
import io.quarkus.qute.EngineBuilder; | ||
import io.quarkus.qute.ResultNode; | ||
|
||
public class MissingCacheConfigurator { | ||
|
||
void configureEngine(@Observes EngineBuilder builder) { | ||
builder.addSectionHelper(new CacheSectionHelper.Factory(new CacheSectionHelper.Cache() { | ||
|
||
@Override | ||
public CompletionStage<ResultNode> getValue(String key, Function<String, CompletionStage<ResultNode>> loader) { | ||
throw new IllegalStateException("#cache cannot be used without the 'quarkus-cache' extension"); | ||
} | ||
})); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...ntime/src/main/java/io/quarkus/qute/runtime/cache/UnsupportedRemoteCacheConfigurator.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,24 @@ | ||
package io.quarkus.qute.runtime.cache; | ||
|
||
import java.util.concurrent.CompletionStage; | ||
import java.util.function.Function; | ||
|
||
import jakarta.enterprise.event.Observes; | ||
|
||
import io.quarkus.qute.CacheSectionHelper; | ||
import io.quarkus.qute.EngineBuilder; | ||
import io.quarkus.qute.ResultNode; | ||
|
||
public class UnsupportedRemoteCacheConfigurator { | ||
|
||
void configureEngine(@Observes EngineBuilder builder) { | ||
builder.addSectionHelper(new CacheSectionHelper.Factory(new CacheSectionHelper.Cache() { | ||
|
||
@Override | ||
public CompletionStage<ResultNode> getValue(String key, Function<String, CompletionStage<ResultNode>> loader) { | ||
throw new IllegalStateException("#cache is not supported for remote caches"); | ||
} | ||
})); | ||
} | ||
|
||
} |