<font size=2 face="sans-serif">My choice is also:</font>
<br><font size=2 face="sans-serif">provide 2 solutions.</font>
<br>
<br><font size=2 face="sans-serif">I would expect most user cases can be
solved by the solution 1. Only advanced users would use the solution 2.</font>
<br>
<br><font size=2 face="sans-serif">Many thanks,<br>
Emily<br>
===========================<br>
Emily Jiang<br>
WebSphere Application Server, CDI Architect, Development Lead</font>
<br><font size=2 face="sans-serif">&nbsp;<br>
MP 211, DE3A20, Winchester, Hampshire, England, SO21 2JN<br>
Phone: &nbsp;+44 (0)1962 816278 &nbsp;Internal: 246278<br>
<br>
Email: emijiang@uk.ibm.com <br>
Lotus Notes: Emily Jiang/UK/IBM@IBMGB<br>
</font>
<br>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">From: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Martin Kouba &lt;mkouba@redhat.com&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">To: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Mark Struberg &lt;struberg@yahoo.de&gt;,
Antoine Sabot-Durand &lt;antoine@sabot-durand.net&gt;, cdi-dev &lt;cdi-dev@lists.jboss.org&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">29/09/2016 12:16</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject: &nbsp; &nbsp;
&nbsp; &nbsp;</font><font size=1 face="sans-serif">Re: [cdi-dev]
Recap of Context Management (CDI-30) hangout meeting</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Sent by: &nbsp; &nbsp;
&nbsp; &nbsp;</font><font size=1 face="sans-serif">cdi-dev-bounces@lists.jboss.org</font>
<br>
<hr noshade>
<br>
<br>
<br><tt><font size=2>Dne 29.9.2016 v 12:59 Mark Struberg napsal(a):<br>
&gt; Martins argument with Quartz is a good one.<br>
&gt;<br>
&gt;<br>
&gt; Having 2 different ways to do the same thing might be making things
too complicated. You also have to think about what happens if a user or
libraries would mix the 2 approaches?<br>
<br>
That's a good point. But I think it should be ok to state that <br>
activate() is no-op if the request context is already active (and the <br>
same for interceptor). I.e. both the interceptor and the <br>
RequestContextControl bean should perform the check described below.<br>
<br>
&gt;<br>
&gt; So my vote is for the programmatic approach.<br>
&gt;<br>
&gt;<br>
&gt; Oh and while we are at it:<br>
&gt; If we introduce some 'RequestContextControl' bean, should it also
contain a isActive() method? Otherwise we might get into troubles with
nesting such code.<br>
&gt; Of course it is possible by code like<br>
&gt;<br>
&gt;<br>
&gt; try {<br>
&gt; &nbsp; beanManager.getContext(RequestScoped.class);<br>
&gt; &nbsp; // request context is active<br>
&gt; }<br>
&gt;<br>
&gt; catch (ContextNotActiveException cnae) {<br>
&gt; &nbsp; // request context is not active<br>
&gt; &nbsp; // start it etc.<br>
&gt;<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; But that seems a bit heavyweight, isn't?<br>
&gt;<br>
&gt; LieGrue,<br>
&gt; strub<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Thursday, 29 September 2016, 11:58, Antoine Sabot-Durand &lt;antoine@sabot-durand.net&gt;
wrote:<br>
&gt;<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; That's also my choice:<br>
&gt;&gt; We should provide 2) for advance usage and consistency sake if
we go for Session context control later AND we should provide 1) for an
easy usage of this feature.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; A well written JavaDoc should prevent confusion between both approach.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Antoine<br>
&gt;&gt;<br>
&gt;&gt; On Thu, Sep 29, 2016 at 11:46 AM Martin Kouba &lt;mkouba@redhat.com&gt;
wrote:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt; Dne 29.9.2016 v 11:16 Antoine Sabot-Durand napsal(a):<br>
&gt;&gt;&gt;&gt; Hi all,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Just to sum up what was said during our Tuesday Hangout
meeting. For<br>
&gt;&gt;&gt;&gt; those who were present feel free to correct or amend this.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Controlling Request Context is something rather easy (because
it's<br>
&gt;&gt;&gt;&gt; linked to one thread) while Session Context is far less
obvious (used<br>
&gt;&gt;&gt;&gt; across multiple threads) so providing a generic solution
to deal with<br>
&gt;&gt;&gt;&gt; their control seems quite complicated.<br>
&gt;&gt;&gt;&gt; That's why we decided to start addressing the Request
Context control<br>
&gt;&gt;&gt;&gt; first and if we fell happy with that, continue the work
on the Session<br>
&gt;&gt;&gt;&gt; Context.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Public API to control the request context could be design
in 2 different<br>
&gt;&gt;&gt;&gt; ways:<br>
&gt;&gt;&gt;&gt; 1) provide an interceptor to activate request context
during the<br>
&gt;&gt;&gt;&gt; intercepted method invocation<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; This approach is also not always usable in some integration
use cases<br>
&gt;&gt;&gt; where the request cannot be simply &quot;wrapped in a single
method call&quot;.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; For instance, in Quartz scheduler you can register a job listener
with<br>
&gt;&gt;&gt; methods jobToBeExecuted(), jobExecutionVetoed() and jobWasExecuted()
-<br>
&gt;&gt;&gt; here the approach 2) would make sense. On the other hand,
you could<br>
&gt;&gt;&gt; implement a JobFactory so that Job instances are beans (or
at least<br>
&gt;&gt;&gt; instances obtained and injected from an InjectionTarget) and
simply<br>
&gt;&gt;&gt; associate interceptor binding for its execute() method.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; 2) provide a programmatic API accessible thru a bean (like
the<br>
&gt;&gt;&gt;&gt; Conversation bean)<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; First solution is probably the easiest way for end user
(to avoid not<br>
&gt;&gt;&gt;&gt; ended context), but if we go for controlling Session Scope
we won't be<br>
&gt;&gt;&gt;&gt; able to provide a simple interceptor for it and will design
something<br>
&gt;&gt;&gt;&gt; like solution 2 for it.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; So the question is should we go for 1 or 2 or both (with
a risk of<br>
&gt;&gt;&gt;&gt; confusion) ?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I think that both ways are legal and make sense.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Thanks for your feedback<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Antoine<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt; cdi-dev mailing list<br>
&gt;&gt;&gt;&gt; cdi-dev@lists.jboss.org<br>
&gt;&gt;&gt;&gt; </font></tt><a href="https://lists.jboss.org/mailman/listinfo/cdi-dev"><tt><font size=2>https://lists.jboss.org/mailman/listinfo/cdi-dev</font></tt></a><tt><font size=2><br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Note that for all code provided on this list, the provider
licenses the code under the Apache License, Version 2 (</font></tt><a href="http://www.apache.org/licenses/LICENSE-2.0.html"><tt><font size=2>http://www.apache.org/licenses/LICENSE-2.0.html</font></tt></a><tt><font size=2>).
For all other ideas provided on this list, the provider waives all patent
and other intellectual property rights inherent in such information.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; cdi-dev mailing list<br>
&gt;&gt; cdi-dev@lists.jboss.org<br>
&gt;&gt; </font></tt><a href="https://lists.jboss.org/mailman/listinfo/cdi-dev"><tt><font size=2>https://lists.jboss.org/mailman/listinfo/cdi-dev</font></tt></a><tt><font size=2><br>
&gt;&gt;<br>
&gt;&gt; Note that for all code provided on this list, the provider licenses
the code under the Apache License, Version 2 (</font></tt><a href="http://www.apache.org/licenses/LICENSE-2.0.html"><tt><font size=2>http://www.apache.org/licenses/LICENSE-2.0.html</font></tt></a><tt><font size=2>).
For all other ideas provided on this list, the provider waives all patent
and other intellectual property rights inherent in such information.<br>
&gt;&gt;<br>
&gt;&gt;<br>
_______________________________________________<br>
cdi-dev mailing list<br>
cdi-dev@lists.jboss.org<br>
</font></tt><a href="https://lists.jboss.org/mailman/listinfo/cdi-dev"><tt><font size=2>https://lists.jboss.org/mailman/listinfo/cdi-dev</font></tt></a><tt><font size=2><br>
<br>
Note that for all code provided on this list, the provider licenses the
code under the Apache License, Version 2 (</font></tt><a href="http://www.apache.org/licenses/LICENSE-2.0.html"><tt><font size=2>http://www.apache.org/licenses/LICENSE-2.0.html</font></tt></a><tt><font size=2>).
For all other ideas provided on this list, the provider waives all patent
and other intellectual property rights inherent in such information.<br>
<br>
</font></tt>
<br><font size=2 face="sans-serif"><br>
Unless stated otherwise above:<br>
IBM United Kingdom Limited - Registered in England and Wales with number
741598. <br>
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU<br>
</font>