<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<base href="https://issues.jboss.org">
<title>Message Title</title>
</head>
<body class="jira" style="color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 1.429">
<table id="background-table" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f5f5f5; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt" bgcolor="#f5f5f5">
<!-- header here -->
<tbody>
<tr>
<td id="header-pattern-container" style="padding: 0px; border-collapse: collapse; padding: 10px 20px">
<table id="header-pattern" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tbody>
<tr>
<td id="header-avatar-image-container" valign="top" style="padding: 0px; border-collapse: collapse; vertical-align: top; width: 32px; padding-right: 8px" width="32"> <img id="header-avatar-image" class="image_fix" src="https://static.jboss.org/developer/gravatar/645210977b379b537aae4a2d7e9103b7?d=mm&s=48" height="32" width="32" border="0" style="border-radius: 3px; vertical-align: top"> </td>
<td id="header-text-container" valign="middle" style="padding: 0px; border-collapse: collapse; vertical-align: middle; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px"> <a class="user-hover" rel="manovotn" id="email_manovotn" href="https://issues.jboss.org/secure/ViewProfile.jspa?name=manovotn" style="color:#0052cc;; color: #3b73af; text-decoration: none">Matej Novotny</a> <strong>updated</strong> an issue </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td id="email-content-container" style="padding: 0px; border-collapse: collapse; padding: 0 20px">
<table id="email-content-table" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-spacing: 0; border-collapse: separate">
<tbody>
<tr>
<!-- there needs to be content in the cell for it to render in some clients -->
<td class="email-content-rounded-top mobile-expand" style="padding: 0px; border-collapse: collapse; color: #ffffff; padding: 0 15px 0 16px; height: 15px; background-color: #ffffff; border-left: 1px solid #cccccc; border-top: 1px solid #cccccc; border-right: 1px solid #cccccc; border-bottom: 0; border-top-right-radius: 5px; border-top-left-radius: 5px; height: 10px; line-height: 10px; padding: 0 15px 0 16px; mso-line-height-rule: exactly" height="10" bgcolor="#ffffff"> </td>
</tr>
<tr>
<td class="email-content-main mobile-expand " style="padding: 0px; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff" bgcolor="#ffffff">
<table class="page-title-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tbody>
<tr>
<td class="page-title-pattern-first-line " style="padding: 0px; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; padding-top: 10px"> <a href="https://issues.jboss.org/browse/WELD" style="color: #3b73af; text-decoration: none">Weld</a> / <a href="https://issues.jboss.org/browse/WELD-2497" style="color: #3b73af; text-decoration: none"><img src="cid:jira-generated-image-avatar-20bba013-b185-4c8d-aa61-de21f3d3b8fe" height="16" width="16" border="0" align="absmiddle" alt="Enhancement" style="vertical-align: text-bottom"></a> <a href="https://issues.jboss.org/browse/WELD-2497" style="color: #3b73af; text-decoration: none">WELD-2497</a> </td>
</tr>
<tr>
<td style="vertical-align: top;; padding: 0px; border-collapse: collapse; padding-right: 5px; font-size: 20px; line-height: 30px; mso-line-height-rule: exactly" class="page-title-pattern-header-container"> <span class="page-title-pattern-header" style="font-family: Arial, sans-serif; padding: 0; font-size: 20px; line-height: 30px; mso-text-raise: 2px; mso-line-height-rule: exactly; vertical-align: middle"> <a href="https://issues.jboss.org/browse/WELD-2497" style="color: #3b73af; text-decoration: none">Weld API - make it possible to propagate built-in contexts</a> </span> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td class="email-content-main mobile-expand wrapper-special-margin" style="padding: 0px; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff; padding-top: 10px; padding-bottom: 5px" bgcolor="#ffffff">
<table class="keyvalue-table" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tbody>
<tr>
<th style="color: #707070; font: normal 14px/20px Arial, sans-serif; text-align: left; vertical-align: top; padding: 2px 0">Change By:</th>
<td style="padding: 0px; border-collapse: collapse; font: normal 14px/20px Arial, sans-serif; padding: 2px 0 2px 5px; vertical-align: top"> <a class="user-hover" rel="manovotn" id="email_manovotn" href="https://issues.jboss.org/secure/ViewProfile.jspa?name=manovotn" style="color:#0052cc;; color: #3b73af; text-decoration: none">Matej Novotny</a> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td class="email-content-main mobile-expand issue-description-container" style="padding: 0px; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff; padding-top: 5px; padding-bottom: 10px" bgcolor="#ffffff">
<table class="text-paragraph-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 2px">
<tbody>
<tr>
<td class="text-paragraph-pattern-container mobile-resize-text " style="padding: 0px; border-collapse: collapse; padding: 0 0 10px 0"> <span class="diffcontext">By definition: <br>bq. A context with a certain scope is said to propagate from one point in the execution of the program to another when the set of mapped instances of contextual types with that scope is preserved.<br><br>Application context is an example of propagating context. However, other built-in normal scopes (such as request context) usually do not propagate and are only bound to a single thread. It seems there are use cases where propagation makes sense (async jax-rs/servlet).<br><br>Weld context management API currently does not allow to:<br><br># *"capture"* the current instances easily ({{javax.enterprise.context.spi.Context#get()}} can only be used if the set of beans for the given scope is known - requires a portable extension etc.)<br># *"clear"* the external storage without destroying the contextual instances (i.e. the context needs to be invalidated before)<br># *"initialize"* the external storage with the map of current instances (e.g. {{HttpServletRequest}} in case of request context bound to {{ServletRequest}}).<br><br>h2. Proposal<br><br>h3.</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> ManagedContext</span> <span class="diffaddedchars" style="background-color:#ddfade;"> Introduce {{WeldAlterableContext}}</span> <span class="diffcontext"><br><br>Add {{org.jboss.weld.context.</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">ManagedContext#getCurrentInstances()</span> <span class="diffaddedchars" style="background-color:#ddfade;">WeldAlterableContext</span> <span class="diffcontext">}}</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> method (name to</span> <span class="diffaddedchars" style="background-color:#ddfade;"> interface into API. This interface will</span> <span class="diffcontext"> be</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> discussed) that returns an immutable map</span> <span class="diffaddedchars" style="background-color:#ddfade;"> implemented by all contexts supporting propagation and will contain methods to *capture* current context state in a given thread returning you a collection</span> <span class="diffcontext"> of</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> {{javax.enterprise.</span> <span class="diffaddedchars" style="background-color:#ddfade;"> all active contextual instances from that</span> <span class="diffcontext">context</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">.spi.Contextual}}</span> <span class="diffaddedchars" style="background-color:#ddfade;"> and</span> <span class="diffcontext"> to</span> <span class="diffaddedchars" style="background-color:#ddfade;"> *clear and set*</span> <span class="diffcontext"> the</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> current instance</span> <span class="diffaddedchars" style="background-color:#ddfade;"> state</span> <span class="diffcontext"> of the</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> contextual type. Contextual is not guaranteed to be designed correctly as</span> <span class="diffaddedchars" style="background-color:#ddfade;"> context, feeding it</span> <span class="diffcontext"> a</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> map key so we might need to return a map</span> <span class="diffaddedchars" style="background-color:#ddfade;"> collection</span> <span class="diffcontext"> of</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> {{org.jboss.weld.serialization.spi.BeanIdentifier}} to current</span> <span class="diffaddedchars" style="background-color:#ddfade;"> contextual</span> <span class="diffcontext"> instances</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> instead. This method would be used to "capture" the</span> <span class="diffaddedchars" style="background-color:#ddfade;"> as its new</span> <span class="diffcontext"> state.</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> By default, the method would throw</span> <span class="diffaddedchars" style="background-color:#ddfade;"><br><br>h3. Introduce helper methods on</span> <span class="diffcontext"> {{</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">UnsupportedOperationException</span> <span class="diffaddedchars" style="background-color:#ddfade;">WeldManager</span> <span class="diffcontext">}}</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">.</span> <span class="diffcontext"><br><br></span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">*UPDATE:* Note that we cannot actually return just a map of</span> <span class="diffcontext"> {{</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">Contextual</span> <span class="diffaddedchars" style="background-color:#ddfade;">WeldManager</span> <span class="diffcontext">}}</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> -> {{Object}} because we need</span> <span class="diffaddedchars" style="background-color:#ddfade;"> will provide additional means</span> <span class="diffcontext"> to</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> preserve</span> <span class="diffaddedchars" style="background-color:#ddfade;"> get hold of all scopes in</span> <span class="diffcontext"> the</span> <span class="diffaddedchars" style="background-color:#ddfade;"> application, subsequently allowing user to grab all underlying contexts (implementing</span> <span class="diffcontext"> {{</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">CreationalContext</span> <span class="diffaddedchars" style="background-color:#ddfade;">WeldAlterableContext</span> <span class="diffcontext">}}</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> too so that we're able to destroy the dependent objects correctly</span> <span class="diffaddedchars" style="background-color:#ddfade;">)</span> <span class="diffcontext">.<br><br>h3.</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> BoundContext</span> <span class="diffaddedchars" style="background-color:#ddfade;"> Compose a human-readable test as an example</span> <span class="diffcontext"><br><br></span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">Add {{org.jboss.weld.context.BoundContext#reset()}} method (name to</span> <span class="diffaddedchars" style="background-color:#ddfade;">Apart from docs, there should</span> <span class="diffcontext"> be</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> discussed)</span> <span class="diffaddedchars" style="background-color:#ddfade;"> an easy to read test</span> <span class="diffcontext"> that</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> would accept a map of {{javax.enterprise.context.spi.Contextual}}</span> <span class="diffaddedchars" style="background-color:#ddfade;"> will show how</span> <span class="diffcontext"> to</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> the current instance of the contextual type</span> <span class="diffaddedchars" style="background-color:#ddfade;"> propagate contexts</span> <span class="diffcontext"> (</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;">or BeanIdentifier->instance, see above</span> <span class="diffaddedchars" style="background-color:#ddfade;">ideally all of them</span> <span class="diffcontext">)</span> <span class="diffaddedchars" style="background-color:#ddfade;"> which will server as a guide for users</span> <span class="diffcontext">.</span> <span class="diffremovedchars" style="background-color: #ffe7e7; text-decoration:line-through;"> This method would be used to "reset" the external storage and clear all threadl local caches. By default, the method would throw {{UnsupportedOperationException}}.</span> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td class="email-content-main mobile-expand " style="padding: 0px; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff" bgcolor="#ffffff">
<table id="actions-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px">
<tbody>
<tr>
<td id="actions-pattern-container" valign="middle" style="padding: 0px; border-collapse: collapse; padding: 10px 0 10px 24px; vertical-align: middle; padding-left: 0">
<table align="left" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tbody>
<tr>
<td class="actions-pattern-action-icon-container" style="padding: 0px; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 0; vertical-align: middle"> <a href="https://issues.jboss.org/browse/WELD-2497#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none"> <img class="actions-pattern-action-icon-image" src="cid:jira-generated-image-static-comment-icon-1e3a77ee-e117-4aef-99e8-04e60cd8abae" alt="Add Comment" title="Add Comment" height="16" width="16" border="0" style="vertical-align: middle"> </a> </td>
<td class="actions-pattern-action-text-container" style="padding: 0px; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 4px; padding-left: 5px"> <a href="https://issues.jboss.org/browse/WELD-2497#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none">Add Comment</a> </td>
</tr>
</tbody>
</table> </td>
</tr>
</tbody>
</table> </td>
</tr>
<!-- there needs to be content in the cell for it to render in some clients -->
<tr>
<td class="email-content-rounded-bottom mobile-expand" style="padding: 0px; border-collapse: collapse; color: #ffffff; padding: 0 15px 0 16px; height: 5px; line-height: 5px; background-color: #ffffff; border-top: 0; border-left: 1px solid #cccccc; border-bottom: 1px solid #cccccc; border-right: 1px solid #cccccc; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; mso-line-height-rule: exactly" height="5" bgcolor="#ffffff"> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td id="footer-pattern" style="padding: 0px; border-collapse: collapse; padding: 12px 20px">
<table id="footer-pattern-container" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tbody>
<tr>
<td id="footer-pattern-text" class="mobile-resize-text" width="100%" style="padding: 0px; border-collapse: collapse; color: #999999; font-size: 12px; line-height: 18px; font-family: Arial, sans-serif; mso-line-height-rule: exactly; mso-text-raise: 2px"> This message was sent by Atlassian Jira <span id="footer-build-information">(v7.12.1#712002-<span title="609a50578ba6bc73dbf8b05dddd7c04a04b6807c" data-commit-id="609a50578ba6bc73dbf8b05dddd7c04a04b6807c}">sha1:609a505</span>)</span> </td>
<td id="footer-pattern-logo-desktop-container" valign="top" style="padding: 0px; border-collapse: collapse; padding-left: 20px; vertical-align: top">
<table style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tbody>
<tr>
<td id="footer-pattern-logo-desktop-padding" style="padding: 0px; border-collapse: collapse; padding-top: 3px"> <img id="footer-pattern-logo-desktop" src="https://issues.jboss.org/images/mail/atlassian-email-logo.png" alt="Atlassian logo" title="Atlassian logo" width="191" height="24" class="image_fix"> </td>
</tr>
</tbody>
</table> </td>
</tr>
</tbody>
</table> </td>
</tr>
</tbody>
</table>
</body>
</html>