Return-Path: X-Original-To: apmail-openwebbeans-user-archive@www.apache.org Delivered-To: apmail-openwebbeans-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5F51311A4A for ; Sun, 13 Jul 2014 08:19:01 +0000 (UTC) Received: (qmail 27056 invoked by uid 500); 13 Jul 2014 08:19:01 -0000 Delivered-To: apmail-openwebbeans-user-archive@openwebbeans.apache.org Received: (qmail 27024 invoked by uid 500); 13 Jul 2014 08:19:01 -0000 Mailing-List: contact user-help@openwebbeans.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@openwebbeans.apache.org Delivered-To: mailing list user@openwebbeans.apache.org Received: (qmail 27014 invoked by uid 99); 13 Jul 2014 08:19:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 Jul 2014 08:19:01 +0000 X-ASF-Spam-Status: No, hits=0.3 required=5.0 tests=FREEMAIL_REPLY,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rmannibucau@gmail.com designates 209.85.216.53 as permitted sender) Received: from [209.85.216.53] (HELO mail-qa0-f53.google.com) (209.85.216.53) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 Jul 2014 08:18:57 +0000 Received: by mail-qa0-f53.google.com with SMTP id v10so2270622qac.12 for ; Sun, 13 Jul 2014 01:18:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=sU/XsvbtLAzKA4ZgxSNsOQ/530H+VUcWO70WCRwMuKA=; b=ul6HynKUMpNFYwksyJVgGnoVLZp02HV1U1CNG17dUkPy3y/nZH0rUlEsYh9Nl+A90t bCSYwsHIjW8bDgfoe8jU2I8MnZb5GFQYCuIgmkC1rrJyS/uDNAz3EOLIH7i1+WO/AiuO q/EIUQvmRGir4qnSgS0N3iAnlmUWCGYuchK5n+E//MVCHC2axcIPIKld+sTUVQsDKD+h XFRHwhIHSTRIrA0hGHTFXg72amsej83U33NSY3RYdymgzWVkHsTf5yetwMtOixM9Hyya I8UEomgYOEDv5HVO7kLVOTPWMDt0Wo6eBEhB0T9ThYAAjbnIit+oiQWQKk/XS8U4AMBU lrMw== X-Received: by 10.140.40.165 with SMTP id x34mr10939682qgx.23.1405239516631; Sun, 13 Jul 2014 01:18:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.96.245.42 with HTTP; Sun, 13 Jul 2014 01:18:16 -0700 (PDT) In-Reply-To: References: <1405198107.92881.YahooMailNeo@web28901.mail.ir2.yahoo.com> From: Romain Manni-Bucau Date: Sun, 13 Jul 2014 10:18:16 +0200 Message-ID: Subject: Re: Question on verifying java classes in a CDI extension To: "user@openwebbeans.apache.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org the idea was to get the proxy for each classes which will get proxied and cache this class. Only issue is to get the proxy you need the Bean related context to be active (which can be false for several contexts) Romain Manni-Bucau Twitter: @rmannibucau Blog: http://rmannibucau.wordpress.com/ LinkedIn: http://fr.linkedin.com/in/rmannibucau Github: https://github.com/rmannibucau 2014-07-13 10:07 GMT+02:00 Lars-Fredrik Smedberg : > @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 > 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" a >> =C3=A9crit : >> >>> @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 >>> 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 >>>> 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> that is a member variable of the CDI extension >>>> 4. The extension is injected into another bean and when the applicatio= n >>>> 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 ne= w >>>> or if its an injected dependent object. However if the object is a nor= mal >>>> 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=C3=A4nlig h=C3=A4lsning / 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 Smedber= g >>>> immediately at itsmeden@gmail.com, and destroy all copies of this >>>> message and any attachments. >>>> >>>> >>> >>> >>> >>> -- >>> Med v=C3=A4nlig h=C3=A4lsning / 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=C3=A4nlig h=C3=A4lsning / 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.