Hi,

The JSF 2.0 spec requires an implementation to support several
annotations, like @ManagedBean.
Has anyone already thought of a possible implementation for this requirement?

IMHO, there is only one option, and that is scanning the classpath at
application startup, because you don't want the overhead with every EL
expression.

But there are some issues with this:
First, what paths to scan? AFAIK the spec doesn't state the classpaths
to scan. I suppose only /WEB-INF/lib and /WEB-INF/classes need to be
checked, but I can't find it in the spec.

And second, how to scan? Reading each *.class file, then creating a
Class instance and then using reflection to scan for annotations is
probably very expensive. Not only the processing time, but I think it
will also become a memory issue because every class in the classpath
will be loaded into memory.
Scanning the plain *.class files is probably not very practical. I
don't know, never tried it, but the class files I've seen don't look
very appealing. :-)

It might be an idea to look at Scannotation, which is an open source
library for scanning jar files for annotations. It works quite good
and it has the advantage of being very efficient because it doesn't
use the default Class/Reflection mechanism.
http://sourceforge.net/projects/scannotation/
The project homepage says it has an Apache 2.0 license, but at the
same time it has a dependency on Javassist (licensed LGPL or MPL) and
the source files don't contain any headers, so it may be not an
option. I don't know, IANAL.

I was playing around with a @ManagedBean annotation parser, but It may
be a good idea to have a discussion on this subject since it probably
has some impact.

What do you think?

Regards,
Jan-Kees

Reply via email to