Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4910B9FB5 for ; Wed, 6 Jun 2012 06:19:53 +0000 (UTC) Received: (qmail 97671 invoked by uid 500); 6 Jun 2012 06:19:52 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 97579 invoked by uid 500); 6 Jun 2012 06:19:52 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 97558 invoked by uid 99); 6 Jun 2012 06:19:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Jun 2012 06:19:51 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=FSL_FREEMAIL_1,FSL_FREEMAIL_2,RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [77.238.189.192] (HELO nm16-vm0.bullet.mail.ird.yahoo.com) (77.238.189.192) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 06 Jun 2012 06:19:42 +0000 Received: from [77.238.189.55] by nm16.bullet.mail.ird.yahoo.com with NNFMP; 06 Jun 2012 06:19:22 -0000 Received: from [212.82.108.124] by tm8.bullet.mail.ird.yahoo.com with NNFMP; 06 Jun 2012 06:19:22 -0000 Received: from [127.0.0.1] by omp1033.mail.ird.yahoo.com with NNFMP; 06 Jun 2012 06:19:22 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 97856.66122.bm@omp1033.mail.ird.yahoo.com Received: (qmail 79047 invoked by uid 60001); 6 Jun 2012 06:19:22 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1338963562; bh=1hyXCZksSpjwyfcEDnZaHGqxDBVdBpfQClU8N6XT+5A=; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=EvSt04+Tta0OW+yrKNsYlrIeTWwz63q2WYa2yYe6jHehU3k2gyjzzyyoUbqJLEXuZQswujfumRg8VHYq+U5A95aG5zn/sypZiFK3NMT2K8hN34z4jknS0ZPCHTMNwFAphEo3+ULoXbhxWvFrEA+KNIs8fEDEwRtcyXqCvELW2as= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.de; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=SliCCr+4LLNtWWmfbauB5HvfxpdcGph3hUuF6uaPKabp6ae9dT21Xdzrfcugc+VGpXb3ikOqDzhya+yyI8v+nTavZCuj9M4ZGIDWY9wlbameAQzZ/SArfIqGDZ59yiohTxXzKV0yReW0kZax8AYFmARYld4sXA99iyQHpbaORzo=; X-YMail-OSG: v_VUZFIVM1k6jIudzLXJbyrYmgIsdB9VmuqIT4NFH._w9Ti XBc7WGR57jv_wPxBc5dKtcTlul7cYaAleWVUkeSNGbqlcpaLoRlqfz5rh.0m WWsf_ATwpykxkA1ytR1SNhVEyfpmffCcPSRHP1B_31HGSxaP5yxsGMEIv2K3 MkEjSmdwElTEixK6wN0mKMBu8HvKz711IU2ObKZjK53Hqt_axeZzIdt4mWtV AYgsL.qzLJ4BwExasB0rxT78w38.gvBrlywjSDqyteOPJ5qdOaBksw6cF_WK xCrALbpQYXAT3pFT_7woOevGQZZgOeCmindr9AYedxVXDI1k1MBOsvD_oqaE aHBxOsKOGTf5nRhxjZYmu785nAR2jeTwK61R2U4gHPWVNom9qPoZvsXNkJN9 QstsfqkhchKwoDmnZKi.1bcZj435dX3mK5h8w3YDJEJEE8gMljdsZYW9Z_Ht A7AKZjRSqAIO.gj7PUoMs3lSrTtdI_nyB5hD9AqNcjS4YArc- Received: from [80.108.122.184] by web171503.mail.ir2.yahoo.com via HTTP; Wed, 06 Jun 2012 07:19:21 BST X-Mailer: YahooMailWebService/0.8.118.349524 References: <0D3FA512-C9BE-41F2-9B63-3EC1294D8940@gmail.com> <6B5AB889-FADE-4029-9134-661F1637459C@gmail.com> <9852109C-FED9-4C6F-9315-93FEFCC99E7D@gmail.com> <1338961804.70469.YahooMailNeo@web171504.mail.ir2.yahoo.com> Message-ID: <1338963561.59179.YahooMailNeo@web171503.mail.ir2.yahoo.com> Date: Wed, 6 Jun 2012 07:19:21 +0100 (BST) From: Mark Struberg Reply-To: Mark Struberg Subject: Re: [classscan] Experiment on xbean-finder To: Commons Developers List In-Reply-To: <1338961804.70469.YahooMailNeo@web171504.mail.ir2.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi!=0A=0AI now moved all the stuff to trunk.=0A=0ANext I'll work on a struc= ture for the API and extract a mainingful api from both Chas' and Davids 'b= ackends' + do the initial maven setup stuff.=0A=0ALieGrue,=0Astrub=0A=0A=0A= =0A----- Original Message -----=0A> From: Mark Struberg = =0A> To: Commons Developers List =0A> Cc: =0A> Sent= : Wednesday, June 6, 2012 7:50 AM=0A> Subject: Re: [classscan] Experiment o= n xbean-finder=0A> =0A>g ood stuff.=0A> =0A> I'd like to go on and do the f= ollowing:=0A> =0A> in ./trunk add the following new directories=0A> =0A> tc= k -> our mass tests, etc which we can use for common testing, performance = =0A> measurements, etc=0A> =0A> api -> the part a user interacts with=0A> i= mpl-bcel -> move Chas' work to=0A> impl-xbf -> move branches/commons-finder= to=0A> =0A> LieGrue,=0A> strub=0A> =0A> =0A> =0A> ----- Original Message -= ----=0A>> From: David Blevins =0A>> To: Commons = Developers List ; =0A> gudnabrsam@gmail.com=0A>> C= c: =0A>> Sent: Wednesday, June 6, 2012 7:32 AM=0A>> Subject: Re: [classsc= an] Experiment on xbean-finder=0A>> =0A>> An expanded view of the info bel= ow in markdown:=0A>> =0A>> =A0 https://gist.github.com/2880038=0A>> =0A>> = Pulled in some also pulled in some Meta-Annotation information from the = =0A>> proposals going around Java EE 7.=A0 There's a lot there, feel free = to =0A> ignore =0A>> it.=A0 Not critical.=0A>> =0A>> =0A>> -David=0A>> = =0A>> =0A>> On Jun 5, 2012, at 9:57 PM, David Blevins wrote:=0A>> =0A>>> = =0A>>> =A0 On Jun 5, 2012, at 1:12 PM, Matt Benson wrote:=0A>>> =0A>>>> =A0= Welcome, David!=0A>>> =0A>>> =A0 Thanks, Matt!=0A>>> =0A>>> =A0 Ok, so I r= efactored it a bit to work in some of the ideas I was =0A> hearing on =0A>>= IRC today.=0A>>> =0A>>> =A0 Those changes were primarily:=0A>>> =A0 - Pro= mote Info objects that represent class data to a separate package =0A> not = =0A>> tied to any bytecode library=0A>>> =A0 - Add listener interface to c= onsume the Info objects=0A>>> =A0 - Added parser abstraction to use ASM or = similar library to create the =0A> Info =0A>> objects and invoke listener= =0A>>> =0A>>> =A0 The code was there and generally written somewhat decoupl= ed with those =0A> =0A>> parts in mind.=A0 Took a bit of snipping and cutt= ing here and there to fully =0A>> decouple it and separate everything out = into separate packages.=0A>>> =0A>>> =A0 There's no ParserFacory yet, that = could easily be created.=A0 I =0A> figured =0A>> there was enough there to= show how things work.=0A>>> =0A>>> =A0 Here's an overview of the code:=0A>= >> =0A>>> =A0 org.apache.commons.classscan.finder=0A>>> =A0 - AnnotationFin= der=0A>>> =A0 - IAnnotationFinder=0A>>> =A0 - ResourceFinder=0A>>> =0A>>> = =A0 AnnotationFinder is essentially the "db" and has methods to =0A>> quer= y.=0A>>> =0A>>> =A0 ResourceFinder is for basic file location such as =0A>>= "META-INF/persistence.xml" and can also be used as part of a =0A>> Servi= ceLoader replacement.=A0 See the ResourceFinder.mdtext for details=0A>>> = =0A>>> =0A>>> =A0 org.apache.commons.classscan.finder.archive=0A>>> =A0 - A= rchive=0A>>> =A0 - ArchiveIterator=0A>>> =A0 - ClassesArchive=0A>>> =A0 - C= lasspathArchive=0A>>> =A0 - CompositeArchive=0A>>> =A0 - FileArchive=0A>>> = =A0 - FilteredArchive=0A>>> =A0 - JarArchive=0A>>> =0A>>> =A0 The Archive i= nterface allows for sources of class files to be =0A> abstracted.=A0 =0A>> = The JarArchive, ClassesArchive and FileArchive are concrete =0A> implement= ations.=A0 =0A>> CompositeArchive is simply a collection of Archive implem= entations.=A0 =0A>> FilteredArchive allows for the archive itself to be fi= ltered in various =0A> ways.=0A>>> =0A>>> =A0 org.apache.commons.classscan.= finder.filter=0A>>> =A0 - ClassFilter=0A>>> =A0 - ContainsFilter=0A>>> =A0 = - ExcludeIncludeFilter=0A>>> =A0 - Filter=0A>>> =A0 - FilterList=0A>>> =A0 = - Filters=0A>>> =A0 - IncludeExcludeFilter=0A>>> =A0 - PackageFilter=0A>>> = =A0 - PatternFilter=0A>>> =A0 - PrefixFilter=0A>>> =A0 - SuffixFilter=0A>>>= =0A>>> =A0 The Filter interface simply allows you to give a yay or nay to = a =0A> String.=A0 =0A>> This is of course useful for greatly limiting the = classes actually scanned =0A> when =0A>> combined with an Archive via wrap= ping it with a FilteredArchive and =0A> supplying a =0A>> Filter.=0A>>> = =0A>>> =A0 FilterList is a Filter implementation that combines one or more = =0A> filters.=A0 =0A>> Both "yes" and "no" filters can be used via =0A>> = IncludeExcludeFilter or ExcludeIncludeFilter which are modeled after HTTPd = =0A>> allowed host pattern.=0A>>> =0A>>> =A0 PackageFilter, ClassFilter, S= uffixFilter, PrefixFilter, ContainsFilter =0A> and =0A>> PatternFilter are= concrete implementations of Filter that each have a =0A> simple =0A>> app= roach to testing the string to give a yay or nay.=0A>>> =0A>>> =A0 The Filt= ers class is a convenience class that makes it easy to =0A> construct =0A>>= the various filters with little syntax as well as performs unwrapping whe= n =0A>> necessary if it sees things like a FilterList with only one filter= or a =0A>> FilterList containing another FilterList.=0A>>> =0A>>> =0A>>> = =A0 org.apache.commons.classscan.finder.meta=0A>>> =A0 - Annotated=0A>>> = =A0 - AnnotatedMember=0A>>> =A0 - AnnotatedMethod=0A>>> =A0 - MetaAnnotated= =0A>>> =A0 - MetaAnnotatedClass=0A>>> =A0 - MetaAnnotatedConstructor=0A>>> = =A0 - MetaAnnotatedElement=0A>>> =A0 - MetaAnnotatedField=0A>>> =A0 - MetaA= nnotatedMethod=0A>>> =A0 - MetaAnnotation=0A>>> =0A>>> =A0 This package pro= vides basic support for meta-annotations which are =0A> simply =0A>> annot= ation reuse or inheritance.=A0 CDI, Bean Validation and JAX-RS all have =0A= >> similar concepts of inheritance.=A0 This code does a more generic appro= ach to =0A> =0A>> reuse that isn't tied to any one particular specificatio= n.=A0 Fun to play =0A> =0A>> with, but not critical to the core concept of= annotation scanning.=0A>>> =0A>>> =A0 org.apache.commons.classscan.finder.= model=0A>>> =A0 - Annotatable=0A>>> =A0 - AnnotationInfo=0A>>> =A0 - ClassI= nfo=0A>>> =A0 - FieldInfo=0A>>> =A0 - Info=0A>>> =A0 - InfoHandler=0A>>> = =A0 - MethodInfo=0A>>> =A0 - PackageInfo=0A>>> =0A>>> =A0 The basic objects= to model class metadata along with a listener.=0A>>> =0A>>> =A0 There coul= d easily be a InfoHandlerList which would be an =0A> implementation of =0A>= > InfoHandler that allowed for a collection of InfoHandlers.=0A>>> =0A>>> = =A0 org.apache.commons.classscan.finder.parse=0A>>> =A0 - AsmParser=0A>>> = =A0 - Parser=0A>>> =0A>>> =A0 Abstracts out the actual bytecode parsing suc= h as ASM.=A0 The parser =0A> need =0A>> only read from the Archive and pro= duce the model of Info objects and invoke =0A> the =0A>> InfoHandler.=0A>>= > =0A>>> =A0 org.apache.commons.classscan.finder.util=0A>>> =A0 - Classes= =0A>>> =A0 - SingleLinkedList=0A>>> =A0 - UriSet=0A>>> =A0 - UrlSet=0A>>> = =0A>>> =A0 Just some utilities.=A0 UrlSet and UriSet are essentially search= able =0A>> collections of URL or URI to allow for something as large as a = classpath of =0A> URLs =0A>> to be easily narrowed.=A0 Was written before = the Filter API and only =0A> partially =0A>> supports it.=A0 Would be nice= to have it updated.=A0 SingleLinkedList is a =0A> minimally =0A>> functio= nal list designed to save memory in the model Info objects.=0A>>> =0A>>> = =0A>>> =A0 Overview of AnnotationFinder methods=0A>>> =0A>>> =A0 =A0 publi= c AnnotationFinder(Archive archive)=0A>>> =0A>>> =A0 Basic constructor.=A0 = The Parser or some ParserFactory should be added.=0A>>> =0A>>> =A0 =A0 pub= lic AnnotationFinder enableMetaAnnotations()=0A>>> =A0 =A0 public Annotati= onFinder enableFindImplementations()=0A>>> =A0 =A0 public AnnotationFinder= enableFindSubclasses()=0A>>> =0A>>> =A0 Methods to enable some heavier lif= ting.=A0 Each has a cost and none are =0A>> essential to basic annotation = scanning.=0A>>> =0A>>> =A0 =A0 public List findAnnotatedPackages(= Class =0A>> Annotation> annotation)=0A>>> =A0 =A0 public L= ist> findAnnotatedClasses(Class> extends Annotation> annot= ation)=0A>>> =A0 =A0 public List findAnnotatedMethods(Class> Annotation> annotation)=0A>>> =A0 =A0 public List = findAnnotatedConstructors(Class =0A>> extends Annotation> annotatio= n)=0A>>> =A0 =A0 public List findAnnotatedFields(Class> Annotation> annotation)=0A>>> =0A>>> =A0 Fairly self explanatory.=0A= >>> =0A>>> =A0 =A0 public List>> =0A>> findMetaAnnotat= edClasses(Class annotation)=0A>>> =A0 =A0 public Lis= t> =0A>> findMetaAnnotatedMethods(Class annotation)=0A>>> =A0 =A0 public List> =0A>> findM= etaAnnotatedFields(Class annotation)=0A>>> =0A>>> =A0= Meta-annotation versions of the above.=A0 Just noticed a couple missing = =0A> :)=0A>>> =0A>>> =A0 =A0 public boolean isAnnotationPresent(Class Annotation> =0A>> annotation)=0A>>> =A0 =A0 public List> findClassesInPackage(String =0A>> packageName, boolean recursive)=0A>>= > =0A>>> =A0 Some trivial utility methods.=0A>>> =0A>>> =A0 =A0 public = List> =0A>> findSubclasses(Class clazz)=0A>>> =A0 = =A0 public List> =0A>> findImplementations(Class= clazz)=0A>>> =0A>>> =A0 These are quite heavy and not recommended for larg= e sets of classes =0A> such as =0A>> the entire JVM classpath.=A0 Works gr= eat for a handful of jars.=A0 Beyond that =0A> is =0A>> not recommended un= less you have heaps of Heap.=0A>>> =0A>>> =A0 =A0 public AnnotationFinder = select(Class... clazz)=0A>>> =A0 =A0 public AnnotationFinder select(Str= ing... clazz)=0A>>> =A0 =A0 public AnnotationFinder select(Iterable clazz)=0A>>> =0A>>> =A0 Newer methods that allow you to narrow down the s= cope of the =0A>> AnnotationFinder.=A0 Say you have a finder for an entire= .war file and you =0A> want to =0A>> get the data for just a jar or speci= fic class or list of classes.=A0 Likely =0A> there =0A>> could be 'join' m= ethods to mirror these.=A0 As well there could be a =0A>> 'select' method = that could easily take a Filter as an arg.=0A>>> =0A>>> =0A>>> =A0 So that'= s more or less what is there :)=A0 Of course anyone is =0A> welcome to =0A>= > play with the code.=A0 Consider it soft.=A0 Delete, add, refactor, whate= ver you =0A> =0A>> want.=A0 It's all in svn so no harm can be done.=A0 Hav= e fun.=0A>>> =0A>>> =0A>>> =A0 Any missing features?=A0 Thoughts?=0A>>> =0A= >>> =0A>>> =A0 -David=0A>>> =0A>> =0A>> =0A>> ----------------------------= -----------------------------------------=0A>> To unsubscribe, e-mail: dev= -unsubscribe@commons.apache.org=0A>> For additional commands, e-mail: dev-= help@commons.apache.org=0A>> =0A> =0A> ------------------------------------= ---------------------------------=0A> To unsubscribe, e-mail: dev-unsubscri= be@commons.apache.org=0A> For additional commands, e-mail: dev-help@commons= .apache.org=0A> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org