org.eclipse.microprofile.context.spi.ThreadContextProvider Java Examples
The following examples show how to use
org.eclipse.microprofile.context.spi.ThreadContextProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ThreadContextTest.java From microprofile-context-propagation with Apache License 2.0 | 6 votes |
@Deployment public static WebArchive createDeployment() { // build a JAR that provides fake 'ThreadPriority' context type JavaArchive threadPriorityContextProvider = ShrinkWrap.create(JavaArchive.class, "threadPriorityContext.jar") .addPackage("org.eclipse.microprofile.context.tck.contexts.priority.spi") .addAsServiceProvider(ThreadContextProvider.class, ThreadPriorityContextProvider.class); // build a JAR that provides two fake context types: 'Buffer' and 'Label' JavaArchive multiContextProvider = ShrinkWrap.create(JavaArchive.class, "bufferAndLabelContext.jar") .addPackages(true, "org.eclipse.microprofile.context.tck.contexts.buffer") .addPackages(true, "org.eclipse.microprofile.context.tck.contexts.label") .addAsServiceProvider(ThreadContextProvider.class, BufferContextProvider.class, LabelContextProvider.class); return ShrinkWrap.create(WebArchive.class, ThreadContextTest.class.getSimpleName() + ".war") .addClass(ThreadContextTest.class) .addAsLibraries(threadPriorityContextProvider, multiContextProvider); }
Example #2
Source File: MPConfigTest.java From microprofile-context-propagation with Apache License 2.0 | 6 votes |
@Deployment public static WebArchive createDeployment() { // build a JAR that provides three fake context types: 'Buffer', 'Label', and 'ThreadPriority' JavaArchive fakeContextProviders = ShrinkWrap.create(JavaArchive.class, "fakeContextTypes.jar") .addPackages(true, "org.eclipse.microprofile.context.tck.contexts.buffer") .addPackages(true, "org.eclipse.microprofile.context.tck.contexts.label") .addPackage("org.eclipse.microprofile.context.tck.contexts.priority.spi") .addAsServiceProvider(ThreadContextProvider.class, BufferContextProvider.class, LabelContextProvider.class, ThreadPriorityContextProvider.class); return ShrinkWrap.create(WebArchive.class, MPConfigTest.class.getSimpleName() + ".war") .addClass(MPConfigBean.class) .addClass(MPConfigTest.class) .addClass(ProducerBean.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .addAsWebInfResource(new StringAsset( "mp.context.ManagedExecutor.maxAsync=1\n" + "mp.context.ManagedExecutor.maxQueued=4\n" + "mp.context.ManagedExecutor.propagated=Label,ThreadPriority\n" + "mp.context.ManagedExecutor.cleared=Remaining\n" + "mp.context.ThreadContext.cleared=Buffer\n" + "mp.context.ThreadContext.propagated=\n" + "mp.context.ThreadContext.unchanged=Remaining"), "classes/META-INF/microprofile-config.properties") .addAsLibraries(fakeContextProviders); }
Example #3
Source File: BasicCDITest.java From microprofile-context-propagation with Apache License 2.0 | 6 votes |
@Deployment public static WebArchive createDeployment() { // build a JAR that provides three fake context types: 'Buffer', 'Label', and 'ThreadPriority' JavaArchive fakeContextProviders = ShrinkWrap.create(JavaArchive.class, "fakeContextTypes.jar") .addPackages(true, "org.eclipse.microprofile.context.tck.contexts.buffer") .addPackages(true, "org.eclipse.microprofile.context.tck.contexts.label") .addPackage("org.eclipse.microprofile.context.tck.contexts.priority.spi") .addAsServiceProvider(ThreadContextProvider.class, BufferContextProvider.class, LabelContextProvider.class, ThreadPriorityContextProvider.class); return ShrinkWrap.create(WebArchive.class, BasicCDITest.class.getSimpleName() + ".war") .addClass(CDIBean.class) .addClass(CdiBeanProducer.class) .addClass(BasicCDITest.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .addAsLibraries(fakeContextProviders); }
Example #4
Source File: ManagedExecutorTest.java From microprofile-context-propagation with Apache License 2.0 | 5 votes |
@Deployment public static WebArchive createDeployment() { // build a JAR that provides three fake context types: 'Buffer', 'Label', and 'ThreadPriority' JavaArchive fakeContextProviders = ShrinkWrap.create(JavaArchive.class, "fakeContextTypes.jar") .addPackages(true, "org.eclipse.microprofile.context.tck.contexts.buffer") .addPackages(true, "org.eclipse.microprofile.context.tck.contexts.label") .addPackage("org.eclipse.microprofile.context.tck.contexts.priority.spi") .addAsServiceProvider(ThreadContextProvider.class, BufferContextProvider.class, LabelContextProvider.class, ThreadPriorityContextProvider.class); return ShrinkWrap.create(WebArchive.class, ManagedExecutorTest.class.getSimpleName() + ".war") .addClass(ManagedExecutorTest.class) .addAsLibraries(fakeContextProviders); }
Example #5
Source File: SmallRyeContextPropagationRecorder.java From quarkus with Apache License 2.0 | 5 votes |
public void configureStaticInit(List<ThreadContextProvider> discoveredProviders, List<ContextManagerExtension> discoveredExtensions) { // build the manager at static init time // in the live-reload mode, the provider instance may be already set in the previous start if (ContextManagerProvider.INSTANCE.get() == null) { ContextManagerProvider contextManagerProvider = new SmallRyeContextManagerProvider(); ContextManagerProvider.register(contextManagerProvider); } // do what config we can here, but we need the runtime executor service to finish builder = (SmallRyeContextManager.Builder) ContextManagerProvider.instance() .getContextManagerBuilder(); builder.withThreadContextProviders(discoveredProviders.toArray(new ThreadContextProvider[0])); builder.withContextManagerExtensions(discoveredExtensions.toArray(new ContextManagerExtension[0])); }