openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lars-Fredrik Smedberg <itsme...@gmail.com>
Subject Re: Question on verifying java classes in a CDI extension
Date Sun, 13 Jul 2014 08:07:53 GMT
@Romain

Thanks for the answer.

About the afterdeployment I not quite understand, could you elaborate a
little bit please on how to do and why it might not work?

Regards
Lars-Fredrik


On Sun, Jul 13, 2014 at 9:34 AM, Romain Manni-Bucau <rmannibucau@gmail.com>
wrote:

> IIRC for weld you can test $Proxy and the package. It is a bit fragile (ie
> will not work with resin for instance) but better than isassignable at
> runtime.
>
> Algo can be: if not in the set try superclass, if superclass in the set
> and a proxy (is there $ and it is not a nested class) then add it to the
> set for next calls.
>
> IsAssignable doest always work (support too much inheritance)
>
> You can also get the proxy in the afterdeployment validation for these
> beans and cache their class name but can imply some context to be active so
> previous algo is still better
> Le 13 juil. 2014 07:13, "Lars-Fredrik Smedberg" <itsmeden@gmail.com> a
> écrit :
>
> @Mark
>>
>> Thanks for the solution, I guess that would work regardless of the
>> underlying proxy technique as well.
>>
>> The "problem" with solution is that I need to traverse the Set and I
>> cannot do a simple set.contains(...), which might not be a big problem
>> since if I get a match I could insert the proxy class in the set as well I
>> guess...
>>
>>
>>
>>
>>
>> On Sat, Jul 12, 2014 at 10:48 PM, Mark Struberg <struberg@yahoo.de>
>> wrote:
>>
>>> maybe it's possible to use Class.isAssignableFrom?
>>>
>>> Because a proxy for the
>>> publuc class MyCustomer
>>>
>>> is basically simply a subclass
>>> public class MyCustomer$$Proxy extends MyCustomer
>>>
>>> LieGrue,
>>> strub
>>>
>>>
>>>   On Saturday, 12 July 2014, 20:52, Lars-Fredrik Smedberg <
>>> itsmeden@gmail.com> wrote:
>>>
>>>
>>>
>>> Hi!
>>>
>>> I have the following scenario:
>>>
>>> 1. A CDI extensions verifies all AnnotatedTypes (in @Observes
>>> ProcessAnnotatedType) that is annotated with a specific annotation
>>> 2. The class (from annotatedType.getJavaClass()) is verified according
>>> to some application specific rules...
>>> 3. If the class has been successfully verified its placed in a
>>> Set<Class<?>> that is a member variable of the CDI extension
>>> 4. The extension is injected into another bean and when the application
>>> is running I would like to check if a specific object has a type that is
>>> amongst the correctly verified types in the Set
>>>
>>> The above works fine if the object to check is an object created by new
>>> or if its an injected dependent object. However if the object is a normal
>>> scoped object the class of the object will
>>> not match any of the classes in the Set because it will be the proxy
>>> class and not the proxied class (which is the one verified and put in the
>>> Set in the CDI extension).
>>>
>>> Is there any other way of doing the above or can I somehow get the
>>> proxied class so I can check if its in the Set?
>>>
>>> Regards
>>> Lars-Fredrik
>>>
>>> --
>>> Med vänlig hälsning / Best regards
>>>
>>> Lars-Fredrik Smedberg
>>>
>>> STATEMENT OF CONFIDENTIALITY:
>>> The information contained in this electronic message and any
>>> attachments to this message are intended for the exclusive use of the
>>> address(es) and may contain confidential or privileged information. If
>>> you are not the intended recipient, please notify Lars-Fredrik Smedberg
>>> immediately at itsmeden@gmail.com, and destroy all copies of this
>>> message and any attachments.
>>>
>>>
>>>
>>
>>
>> --
>> Med vänlig hälsning / Best regards
>>
>> Lars-Fredrik Smedberg
>>
>> STATEMENT OF CONFIDENTIALITY:
>> The information contained in this electronic message and any
>> attachments to this message are intended for the exclusive use of the
>> address(es) and may contain confidential or privileged information. If
>> you are not the intended recipient, please notify Lars-Fredrik Smedberg
>> immediately at itsmeden@gmail.com, and destroy all copies of this
>> message and any attachments.
>>
>


-- 
Med vänlig hälsning / Best regards

Lars-Fredrik Smedberg

STATEMENT OF CONFIDENTIALITY:
The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
address(es) and may contain confidential or privileged information. If
you are not the intended recipient, please notify Lars-Fredrik Smedberg
immediately at itsmeden@gmail.com, and destroy all copies of this
message and any attachments.

Mime
View raw message