SPI for propagation of third-party context types #149
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull copies over the SPI from MicroProfile Context Propagation that allows for third-party providers of thread context. This will be necessary for propagation of CDI context, for example, to be handled by a third-party implementation, such as Weld, but driven by the implementor of the Jakarta Concurrency specification.
One of the main decisions to make in adding this is whether the SPI should allow for serializable thread context to enable the 4 ContextService.createContextualProxy methods that let you create contextual proxies that can be serialized and deserialized across JVMs. MicroProfile avoided the need for serializable thread context by excluding these methods. We could do that, too, by declaring that the combination of third-party thread context with the createContextualProxy methods is only valid if the interface types are not serializable. That could simplify things for providers of third-party context. It could also be limiting in scenarios such as persistent (EJB) timers and potentially batch that might use the ContextService to store contextual tasks and expect them to be able to run on another JVM. I'll start a discussion on the mailing list about this.
An update to the above - I joined a call with the CDI spec group about this SPI, and the feedback from them is a strong preference to leave out the serializable aspect. Serialization gets too confusing and complex as to the very limited number of scenarios in which it could actually work. I have updated this pull with a second commit that takes away the serialization/deserialization of context. If anyone would like to see what it looked like prior to that point, that can be seen with just the first commit.
Signed-off-by: Nathan Rauh nathan.rauh@us.ibm.com