-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ArC - introduce the CurrentContextFactory abstraction
- this API allows quarkus to supply an optimized backend for a context of a normal scope - currently it's only used by the request context - an extension can provide a custom factory via CurrentContextFactoryBuildItem
- Loading branch information
Showing
12 changed files
with
181 additions
and
50 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
22 changes: 22 additions & 0 deletions
22
...rc/deployment/src/main/java/io/quarkus/arc/deployment/CurrentContextFactoryBuildItem.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,22 @@ | ||
package io.quarkus.arc.deployment; | ||
|
||
import io.quarkus.arc.CurrentContextFactory; | ||
import io.quarkus.builder.item.SimpleBuildItem; | ||
import io.quarkus.runtime.RuntimeValue; | ||
|
||
/** | ||
* An extension can provide a custom {@link CurrentContextFactory}. | ||
*/ | ||
public final class CurrentContextFactoryBuildItem extends SimpleBuildItem { | ||
|
||
private final RuntimeValue<CurrentContextFactory> factory; | ||
|
||
public CurrentContextFactoryBuildItem(RuntimeValue<CurrentContextFactory> factory) { | ||
this.factory = factory; | ||
} | ||
|
||
public RuntimeValue<CurrentContextFactory> getFactory() { | ||
return factory; | ||
} | ||
|
||
} |
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
31 changes: 31 additions & 0 deletions
31
independent-projects/arc/runtime/src/main/java/io/quarkus/arc/CurrentContext.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,31 @@ | ||
package io.quarkus.arc; | ||
|
||
import io.quarkus.arc.InjectableContext.ContextState; | ||
|
||
/** | ||
* Represents the current context of a normal scope. | ||
* | ||
* @param <T> | ||
* @see CurrentContextFactory | ||
*/ | ||
public interface CurrentContext<T extends ContextState> { | ||
|
||
/** | ||
* | ||
* @return the current state | ||
*/ | ||
T get(); | ||
|
||
/** | ||
* Sets the current state. | ||
* | ||
* @param state | ||
*/ | ||
void set(T state); | ||
|
||
/** | ||
* Removes the current state. | ||
*/ | ||
void remove(); | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
independent-projects/arc/runtime/src/main/java/io/quarkus/arc/CurrentContextFactory.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,15 @@ | ||
package io.quarkus.arc; | ||
|
||
import io.quarkus.arc.InjectableContext.ContextState; | ||
import java.lang.annotation.Annotation; | ||
|
||
/** | ||
* This factory can be used to create a new {@link CurrentContext} for a normal scope, e.g. for | ||
* {@link javax.enterprise.context.RequestScoped}. It's usually not necessary for shared contexts, such as | ||
* {@link javax.enterprise.context.ApplicationScoped}. | ||
*/ | ||
public interface CurrentContextFactory { | ||
|
||
<T extends ContextState> CurrentContext<T> create(Class<? extends Annotation> scope); | ||
|
||
} |
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
Oops, something went wrong.