Return-Path: Delivered-To: apmail-myfaces-dev-archive@www.apache.org Received: (qmail 44879 invoked from network); 18 Jan 2009 13:51:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Jan 2009 13:51:30 -0000 Received: (qmail 33836 invoked by uid 500); 18 Jan 2009 13:51:29 -0000 Delivered-To: apmail-myfaces-dev-archive@myfaces.apache.org Received: (qmail 33792 invoked by uid 500); 18 Jan 2009 13:51:29 -0000 Mailing-List: contact dev-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Development" Delivered-To: mailing list dev@myfaces.apache.org Received: (qmail 33783 invoked by uid 99); 18 Jan 2009 13:51:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Jan 2009 05:51:29 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of cagatay.civici@gmail.com designates 74.125.78.145 as permitted sender) Received: from [74.125.78.145] (HELO ey-out-1920.google.com) (74.125.78.145) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Jan 2009 13:51:19 +0000 Received: by ey-out-1920.google.com with SMTP id 4so253338eyg.24 for ; Sun, 18 Jan 2009 05:50:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=wksbqJDhTDPT5oxaCzMQSBTghbGeL2hW6k2SUJoUFWc=; b=bZVD+eIutt2oCl4aHpyhHmCRzKm93MB7MxvEdTCbkbl7jo8jpJGczkw2qBXpuv5JrP IY/qAqvE5rU3AYr6m4emb41M8tfc24bsDpT0i6MZY5Rxd+lKq37lF3XVLyA9tgS+AOWZ XU5HxxnMuMX8NM4uDfh+LSNACjsCYrHn4hoDo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=uzGHyE+WNkRfX3CH7oQ/4KS8r24JgNc1ciGeTvKcYa8pB+YqkNlGmvgbqksjAlIFO7 aUVJyo/lIpgfBl24YoC+uFDwDXHhnWssAzosdhiwfmg8/1zkNTgLKQnJTyuim96u1Avd 7In3Ta5dI6Fx7+szUrLEI5rQ0HKvaS6hz+36c= Received: by 10.210.144.3 with SMTP id r3mr4504138ebd.30.1232286657957; Sun, 18 Jan 2009 05:50:57 -0800 (PST) Received: by 10.210.91.3 with HTTP; Sun, 18 Jan 2009 05:50:57 -0800 (PST) Message-ID: <8c9d4eaa0901180550x24aea286y190db1dacbf6cd27@mail.gmail.com> Date: Sun, 18 Jan 2009 13:50:57 +0000 From: "Cagatay Civici" To: "MyFaces Development" Subject: Re: Scanning for annotated classes in MyFaces 2 In-Reply-To: <237ac0b0901180541k4e848a10k63330a26b2163a63@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_9829_27905403.1232286657957" References: <237ac0b0901061232v393cd58fma22efb24429faf1e@mail.gmail.com> <71235db40901101857x3241f335g8d7ee3d8ae320c50@mail.gmail.com> <71235db40901110651x53f84058v2a960a9b65a6fa85@mail.gmail.com> <237ac0b0901180541k4e848a10k63330a26b2163a63@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_9829_27905403.1232286657957 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Jan, Thanks for your contribution, yes this could be done without adding a dependency. We could avoid reflection stuff and use byte code exploring. Mojarra 2.0 uses code from Glassfish codebase for this byte code stuff btw. You may take a look at their implementation to give an idea. I agree that a custom scan path should fasten the app startup time a lot, usually the annotated classes belong to a certain package in our apps like com.mycompany.myproject.* Cheers, Cagatay On Sun, Jan 18, 2009 at 1:41 PM, Jan-Kees van Andel < jankeesvanandel@gmail.com> wrote: > 2009/1/11 Matthias Wessendorf : > > On Sun, Jan 11, 2009 at 4:46 AM, Mario Ivankovits > wrote: > > > > ;-) I really hate to wait on the boot-up. > > :-) > > > > -- > > Matthias Wessendorf > > > > blog: http://matthiaswessendorf.wordpress.com/ > > sessions: http://www.slideshare.net/mwessendorf > > twitter: http://twitter.com/mwessendorf > > > > Last week I've been playing around with a (non-Reflection) classpath > scanner of my own. It's actually not that hard to write (if you have > the class file format specification somewhere for reference) and my > experience until now is that it's much faster than using Reflection. > > I have a test webapp which I deploy on Tomcat. This webapp contains > about 650 classes. > > With reflection, it takes about 1500ms to read them all, with my > custom home brewn scanner, it only takes between 300ms and 350ms. > The only performance tweak I have made was a BufferedInputStream, so > I'm sure there is enough room for other improvements (maybe some > fork-join algorithm to support parallelism). > I haven't really tested memory footprint yet, but 650 classes is still > not that much. > > Current status (I do this in spare time ;-)): > - Expose the parsed classes in a developer-friendly format, instead of > the raw class file format. (it's like a lite version of the Reflection > API, to keep it fast). > - Read classes in jars. > - Test for possible ClassLoader issues. > - Allow users to specify their own searchpaths. > - Package filtering. > - Search/filter API to allow the developer to only load classes that > implement some interface or are tagged with an annotation. > > If I'm satisfied with the results, we can see if it may fit into > MyFaces (or maybe a reusable utility, since there are other projects > that need to scan for annotations). > It's not that much code and this way there is no need for an > additional dependency. > > I'll keep you guys informed. > > Regards, > > /Jan-Kees > ------=_Part_9829_27905403.1232286657957 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Jan,

Thanks for your contribution, yes this could be done without adding a dependency.

We could avoid reflection stuff and use byte code exploring. Mojarra 2.0 uses code from Glassfish codebase for this byte code stuff btw. You may take a look at their implementation to give an idea.

I agree that a custom scan path should fasten the app startup time a lot, usually the annotated classes belong to a certain package in our apps like

com.mycompany.myproject.*

Cheers,

Cagatay

On Sun, Jan 18, 2009 at 1:41 PM, Jan-Kees van Andel <jankeesvanandel@gmail.com> wrote:
2009/1/11 Matthias Wessendorf <matzew@apache.org>:
> On Sun, Jan 11, 2009 at 4:46 AM, Mario Ivankovits <mario@ops.co.at> wrote:
>
> ;-) I really hate to wait on the boot-up.
> :-)
>
> --
> Matthias Wessendorf
>
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> twitter: http://twitter.com/mwessendorf
>

Last week I've been playing around with a (non-Reflection) classpath
scanner of my own. It's actually not that hard to write (if you have
the class file format specification somewhere for reference) and my
experience until now is that it's much faster than using Reflection.

I have a test webapp which I deploy on Tomcat. This webapp contains
about 650 classes.

With reflection, it takes about 1500ms to read them all, with my
custom home brewn scanner, it only takes between 300ms and 350ms.
The only performance tweak I have made was a BufferedInputStream, so
I'm sure there is enough room for other improvements (maybe some
fork-join algorithm to support parallelism).
I haven't really tested memory footprint yet, but 650 classes is still
not that much.

Current status (I do this in spare time ;-)):
- Expose the parsed classes in a developer-friendly format, instead of
the raw class file format. (it's like a lite version of the Reflection
API, to keep it fast).
- Read classes in jars.
- Test for possible ClassLoader issues.
- Allow users to specify their own searchpaths.
- Package filtering.
- Search/filter API to allow the developer to only load classes that
implement some interface or are tagged with an annotation.

If I'm satisfied with the results, we can see if it may fit into
MyFaces (or maybe a reusable utility, since there are other projects
that need to scan for annotations).
It's not that much code and this way there is no need for an
additional dependency.

I'll keep you guys informed.

Regards,

/Jan-Kees

------=_Part_9829_27905403.1232286657957--