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.
Make a custom ContextManagerProvider with a single manager
Because Quarkus doesn't care about one-per CL and Franz said this is a bottleneck for some reason
- Loading branch information
Showing
2 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...time/src/main/java/io/quarkus/smallrye/context/runtime/QuarkusContextManagerProvider.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,42 @@ | ||
package io.quarkus.smallrye.context.runtime; | ||
|
||
import org.eclipse.microprofile.context.spi.ContextManager; | ||
|
||
import io.smallrye.context.SmallRyeContextManager; | ||
import io.smallrye.context.SmallRyeContextManagerProvider; | ||
|
||
/** | ||
* Quarkus doesn't need one manager per CL, we only have the one | ||
*/ | ||
public class QuarkusContextManagerProvider extends SmallRyeContextManagerProvider { | ||
|
||
private SmallRyeContextManager contextManager; | ||
|
||
@Override | ||
public SmallRyeContextManager getContextManager(ClassLoader classLoader) { | ||
return contextManager; | ||
} | ||
|
||
@Override | ||
public SmallRyeContextManager getContextManager() { | ||
return contextManager; | ||
} | ||
|
||
@Override | ||
public ContextManager findContextManager(ClassLoader classLoader) { | ||
return contextManager; | ||
} | ||
|
||
@Override | ||
public void registerContextManager(ContextManager manager, ClassLoader classLoader) { | ||
if (manager instanceof SmallRyeContextManager == false) { | ||
throw new IllegalArgumentException("Only instances of SmallRyeContextManager are supported: " + manager); | ||
} | ||
contextManager = (SmallRyeContextManager) manager; | ||
} | ||
|
||
@Override | ||
public void releaseContextManager(ContextManager manager) { | ||
contextManager = null; | ||
} | ||
} |
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