<div dir="ltr">We had similar challenges and discussions even before JSR 363 about knowing what type of quantity you're dealing with types like<div><pre style="font-size:1.3em;margin-top:0px;color:rgb(53,56,51)"><span class="gmail-strong" style="font-weight:bold">Unit<Q extends <a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Quantity.html" title="interface in javax.measure" style="text-decoration-line:none;color:rgb(76,107,135)">Quantity</a><Q>></span></pre></div><div>I can only confirm Arjan's impression. And I had numerous conversations with Andrew Kennedy, the Chief Architect behind the F# Units of Measurement support and other .NET libraries about it. Where he mentioned shortcomings of the Java language especially the lack of Reified Generics (<a href="http://stackoverflow.com/questions/31876372/what-is-reification">http://stackoverflow.com/questions/31876372/what-is-reification</a>), which C#, F# or other .NET languages got, but Java won't at least not until Java 10, 11 or even later.</div><div><br></div><div>I tried a lot between 2010 and now but so far none of these Reflection tricks and approaches were stable enough, so not sure, if it'll work any better in this case (unless you implement CDI in C#;-)</div><div><br></div><div><span lang="EN-US" style="font-family:arial,helvetica,sans-serif;font-size:x-small">Werner</span></div><div class="gmail_extra"><div><div class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><span lang="EN-GB"><div style="font-family:arial,helvetica,sans-serif"><br></div></span></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Wed, Apr 26, 2017 at 5:29 PM, <span dir="ltr"><<a href="mailto:cdi-dev-request@lists.jboss.org" target="_blank">cdi-dev-request@lists.jboss.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Send cdi-dev mailing list submissions to<br>
<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/cdi-dev</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:cdi-dev-request@lists.jboss.org">cdi-dev-request@lists.jboss.<wbr>org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:cdi-dev-owner@lists.jboss.org">cdi-dev-owner@lists.jboss.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of cdi-dev digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Types of Principal object (John Ament)<br>
2. Re: Types of Principal object (Romain Manni-Bucau)<br>
3. Re: Types of Principal object (Matej Novotny)<br>
4. Re: Types of Principal object (arjan tijms)<br>
<br>
<br>
------------------------------<wbr>------------------------------<wbr>----------<br>
<br>
Message: 1<br>
Date: Wed, 26 Apr 2017 13:54:57 +0000<br>
From: John Ament <<a href="mailto:john.ament@spartasystems.com">john.ament@spartasystems.com</a>><br>
Subject: [cdi-dev] Types of Principal object<br>
To: cdi-dev <<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>><br>
Message-ID:<br>
<<a href="mailto:CY4PR04MB048607BF779F8680ED5CE53898110@CY4PR04MB0486.namprd04.prod.outlook.com">CY4PR04MB048607BF779F8680ED5C<wbr>E53898110@CY4PR04MB0486.<wbr>namprd04.prod.outlook.com</a>><br>
<br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
Hey guys<br>
<br>
<br>
I raised a bug against the Weld guys, but think its worth an EG discussion. When a Principal object is injected, the only type it has is Principal. It does not retain the actual type used at runtime. This threw me off on some Keycloak integration I'm working on (in $dayjob). So I was wondering, is this expected from our POV or should it retain the types of the actual runtime instance?<br>
<br>
<br>
John<br>
<br>
______________________________<wbr>__<br>
NOTICE: This e-mail message and any attachments may contain confidential, proprietary, and/or privileged information which should be treated accordingly. If you are not the intended recipient, please notify the sender immediately by return e-mail, delete this message, and destroy all physical and electronic copies. Thank you.<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.jboss.org/pipermail/cdi-dev/attachments/20170426/b6740722/attachment-0001.html" rel="noreferrer" target="_blank">http://lists.jboss.org/<wbr>pipermail/cdi-dev/attachments/<wbr>20170426/b6740722/attachment-<wbr>0001.html</a><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Wed, 26 Apr 2017 16:38:01 +0200<br>
From: Romain Manni-Bucau <<a href="mailto:rmannibucau@gmail.com">rmannibucau@gmail.com</a>><br>
Subject: Re: [cdi-dev] Types of Principal object<br>
To: John Ament <<a href="mailto:john.ament@spartasystems.com">john.ament@spartasystems.com</a>><br>
Cc: cdi-dev <<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>><br>
Message-ID:<br>
<CACLE=7N=<a href="mailto:pkvZDX3ULCFAK2Fhw8-bH0pbOsqctqsbkPhKk8i1VA@mail.gmail.com">pkvZDX3ULCFAK2Fhw8-<wbr>bH0pbOsqctqsbkPhKk8i1VA@mail.<wbr>gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Hi John,<br>
<br>
agree CDI/security integration (mainly through Principal bean) is<br>
completely unusable in practise cause Principal type is too simple (name<br>
only) and casting is needed in 99.99% of apps. AFAIK It is tracked at<br>
<a href="https://issues.jboss.org/browse/CDI-597" rel="noreferrer" target="_blank">https://issues.jboss.org/<wbr>browse/CDI-597</a>.<br>
<br>
<br>
Romain Manni-Bucau<br>
@rmannibucau <<a href="https://twitter.com/rmannibucau" rel="noreferrer" target="_blank">https://twitter.com/<wbr>rmannibucau</a>> | Blog<br>
<<a href="https://blog-rmannibucau.rhcloud.com" rel="noreferrer" target="_blank">https://blog-rmannibucau.<wbr>rhcloud.com</a>> | Old Blog<br>
<<a href="http://rmannibucau.wordpress.com" rel="noreferrer" target="_blank">http://rmannibucau.wordpress.<wbr>com</a>> | Github <<a href="https://github.com/rmannibucau" rel="noreferrer" target="_blank">https://github.com/<wbr>rmannibucau</a>> |<br>
LinkedIn <<a href="https://www.linkedin.com/in/rmannibucau" rel="noreferrer" target="_blank">https://www.linkedin.com/in/<wbr>rmannibucau</a>> | JavaEE Factory<br>
<<a href="https://javaeefactory-rmannibucau.rhcloud.com" rel="noreferrer" target="_blank">https://javaeefactory-<wbr>rmannibucau.rhcloud.com</a>><br>
<br>
2017-04-26 15:54 GMT+02:00 John Ament <<a href="mailto:john.ament@spartasystems.com">john.ament@spartasystems.com</a>><wbr>:<br>
<br>
> Hey guys<br>
><br>
><br>
> I raised a bug against the Weld guys, but think its worth an EG<br>
> discussion. When a Principal object is injected, the only type it has is<br>
> Principal. It does not retain the actual type used at runtime. This threw<br>
> me off on some Keycloak integration I'm working on (in $dayjob). So I was<br>
> wondering, is this expected from our POV or should it retain the types of<br>
> the actual runtime instance?<br>
><br>
><br>
> John<br>
><br>
> ------------------------------<br>
> NOTICE: This e-mail message and any attachments may contain confidential,<br>
> proprietary, and/or privileged information which should be treated<br>
> accordingly. If you are not the intended recipient, please notify the<br>
> sender immediately by return e-mail, delete this message, and destroy all<br>
> physical and electronic copies. Thank you.<br>
><br>
> ______________________________<wbr>_________________<br>
> cdi-dev mailing list<br>
> <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/cdi-dev</a><br>
><br>
> Note that for all code provided on this list, the provider licenses the<br>
> code under the Apache License, Version 2 (<a href="http://www.apache.org/" rel="noreferrer" target="_blank">http://www.apache.org/</a><br>
> licenses/LICENSE-2.0.html). For all other ideas provided on this list,<br>
> the provider waives all patent and other intellectual property rights<br>
> inherent in such information.<br>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.jboss.org/pipermail/cdi-dev/attachments/20170426/19976ebd/attachment-0001.html" rel="noreferrer" target="_blank">http://lists.jboss.org/<wbr>pipermail/cdi-dev/attachments/<wbr>20170426/19976ebd/attachment-<wbr>0001.html</a><br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Wed, 26 Apr 2017 10:48:40 -0400 (EDT)<br>
From: Matej Novotny <<a href="mailto:manovotn@redhat.com">manovotn@redhat.com</a>><br>
Subject: Re: [cdi-dev] Types of Principal object<br>
To: John Ament <<a href="mailto:john.ament@spartasystems.com">john.ament@spartasystems.com</a>><br>
Cc: cdi-dev <<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>><br>
Message-ID:<br>
<<a href="mailto:1098875365.1348630.1493218120014.JavaMail.zimbra@redhat.com">1098875365.1348630.<wbr>1493218120014.JavaMail.zimbra@<wbr>redhat.com</a>><br>
Content-Type: text/plain; charset=utf-8<br>
<br>
Hey John,<br>
<br>
just to shed some light.<br>
One of the reasons it works this way is because the types the actual Principal has might not be proxyable.<br>
And spec requires all built-in beans to be decorable - e.g. you need them to be proxyable (although the added value of principal decorator is ...eh, disputable at best?).<br>
<br>
Therefore, it is safer/viable to create a proxyable wrapper object which implements Principal only and delegetas calls (that's what Weld does).<br>
<br>
Otherwise I agree it could be nice to ahve a way to cast the object as the pure Principal interface doesn't help much.<br>
<br>
Matej<br>
<br>
----- Original Message -----<br>
> From: "John Ament" <<a href="mailto:john.ament@spartasystems.com">john.ament@spartasystems.com</a>><br>
> To: "cdi-dev" <<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>><br>
> Sent: Wednesday, April 26, 2017 3:54:57 PM<br>
> Subject: [cdi-dev] Types of Principal object<br>
><br>
><br>
><br>
> Hey guys<br>
><br>
><br>
><br>
><br>
> I raised a bug against the Weld guys, but think its worth an EG discussion.<br>
> When a Principal object is injected, the only type it has is Principal. It<br>
> does not retain the actual type used at runtime. This threw me off on some<br>
> Keycloak integration I'm working on (in $dayjob). So I was wondering, is<br>
> this expected from our POV or should it retain the types of the actual<br>
> runtime instance?<br>
><br>
><br>
><br>
><br>
> John<br>
><br>
><br>
><br>
><br>
> NOTICE: This e-mail message and any attachments may contain confidential,<br>
> proprietary, and/or privileged information which should be treated<br>
> accordingly. If you are not the intended recipient, please notify the sender<br>
> immediately by return e-mail, delete this message, and destroy all physical<br>
> and electronic copies. Thank you.<br>
><br>
> ______________________________<wbr>_________________<br>
> cdi-dev mailing list<br>
> <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/cdi-dev</a><br>
><br>
> Note that for all code provided on this list, the provider licenses the code<br>
> under the Apache License, Version 2<br>
> (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/<wbr>licenses/LICENSE-2.0.html</a>). For all other ideas<br>
> provided on this list, the provider waives all patent and other intellectual<br>
> property rights inherent in such information.<br>
<br>
<br>
------------------------------<br>
<br>
Message: 4<br>
Date: Wed, 26 Apr 2017 17:11:11 +0200<br>
From: arjan tijms <<a href="mailto:arjan.tijms@gmail.com">arjan.tijms@gmail.com</a>><br>
Subject: Re: [cdi-dev] Types of Principal object<br>
To: John Ament <<a href="mailto:john.ament@spartasystems.com">john.ament@spartasystems.com</a>><br>
Cc: cdi-dev <<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>><br>
Message-ID:<br>
<CAE=-<wbr>AhA0PiXZpSKmy0XYoMxCFuyxjV3Wt=<wbr>jjFzhC=<a href="mailto:G%2BLOc9TDA@mail.gmail.com">G+LOc9TDA@mail.gmail.<wbr>com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Hi,<br>
<br>
We discussed this very issue in the Security API EG as well. In the<br>
Security API the actual type *MUST* be retained as per the spec definition.<br>
<br>
The problem in CDI, at least in Weld, is that a proxy is injected. This<br>
happens via the build-in bean "PrincipalBean extends AbstractEEBean", where<br>
AbstractEEBean does:<br>
<br>
public abstract class AbstractEEBean<T> extends<br>
AbstractStaticallyDecorableBui<wbr>ltInBean<T> {<br>
<br>
private final T proxy;<br>
<br>
protected AbstractEEBean(Class<T> type, Callable<T> callable,<br>
BeanManagerImpl beanManager) {<br>
super(beanManager, type);<br>
this.proxy = new ProxyFactory<T>(beanManager.<wbr>getContextId(), type,<br>
getTypes(), this).create(new EnterpriseTargetBeanInstance(<wbr>type, new<br>
CallableMethodHandler(<wbr>callable)));<br>
}<br>
// ...<br>
}<br>
<br>
I'm not even sure if it's possible to downcast the proxy to the required<br>
runtime type.<br>
<br>
Also note that the Principal can change during the request. The simplest<br>
case is when during an http request HttpServletRequest#logout is called.<br>
<br>
Kind regards,<br>
Arjan Tijms<br>
<br>
<br>
<br>
<br>
On Wed, Apr 26, 2017 at 3:54 PM, John Ament <<a href="mailto:john.ament@spartasystems.com">john.ament@spartasystems.com</a>><br>
wrote:<br>
<br>
> Hey guys<br>
><br>
><br>
> I raised a bug against the Weld guys, but think its worth an EG<br>
> discussion. When a Principal object is injected, the only type it has is<br>
> Principal. It does not retain the actual type used at runtime. This threw<br>
> me off on some Keycloak integration I'm working on (in $dayjob). So I was<br>
> wondering, is this expected from our POV or should it retain the types of<br>
> the actual runtime instance?<br>
><br>
><br>
> John<br>
><br>
> ------------------------------<br>
> NOTICE: This e-mail message and any attachments may contain confidential,<br>
> proprietary, and/or privileged information which should be treated<br>
> accordingly. If you are not the intended recipient, please notify the<br>
> sender immediately by return e-mail, delete this message, and destroy all<br>
> physical and electronic copies. Thank you.<br>
><br>
> ______________________________<wbr>_________________<br>
> cdi-dev mailing list<br>
> <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/cdi-dev</a><br>
><br>
> Note that for all code provided on this list, the provider licenses the<br>
> code under the Apache License, Version 2 (<a href="http://www.apache.org/" rel="noreferrer" target="_blank">http://www.apache.org/</a><br>
> licenses/LICENSE-2.0.html). For all other ideas provided on this list,<br>
> the provider waives all patent and other intellectual property rights<br>
> inherent in such information.<br>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.jboss.org/pipermail/cdi-dev/attachments/20170426/206ff811/attachment.html" rel="noreferrer" target="_blank">http://lists.jboss.org/<wbr>pipermail/cdi-dev/attachments/<wbr>20170426/206ff811/attachment.<wbr>html</a><br>
<br>
------------------------------<br>
<br>
______________________________<wbr>_________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/cdi-dev</a><br>
<br>
Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/<wbr>licenses/LICENSE-2.0.html</a>). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.<br>
<br>
End of cdi-dev Digest, Vol 77, Issue 8<br>
******************************<wbr>********<br>
</blockquote></div><br></div></div>