What if ServiceResources implemented new methods to gain access to
annotations (that would be a merge of interface annotations and
implementation class annotations).

On Thu, May 20, 2010 at 2:52 PM, Thiago H. de Paula Figueiredo
<[email protected]> wrote:
> On Thu, 20 May 2010 18:09:05 -0300, Igor Drobiazko
> <[email protected]> wrote:
>
>> As Thiago already mentioned annotations & proxies are very annoying right
>> now. Maybe I'll have a look at this too.
>
> I've took a look and, given the free time I had at the moment, I couldn't
> find a complete solution for it ClassFab gets in the way. On the other hand,
> I've found some code that copies annotations in Javassist. I pasted it in
> the end of this message.
>
> Thinking about proxies, I wondered if on-the-fly source code generation and
> compilation wouldn't be a solution. Java 6 provides a well-defined compiler
> API, 5 doesn't, but we could work around this. I've been using the
> FreeMarker template engine to generate source code with success.
>
>> Also integration with CDI is a must have for marketing stuff. It would be
>> nice to make Tapestry CDI compliant with "standards".
>
> We could create a module that provides Tapestry-IoC as a CDI portable
> extension. The documentation is here:
> http://docs.jboss.org/weld/reference/1.0.1-Final/en-US/html/extend.html.
> This feature, when the annotation in service methods issue is fixed, will
> allow us to use T-IoC like distributed configuration and use EJB features,
> like transaction management, at the same time. Best of two worlds. :)
>
> From
> http://repo.aduna-software.org/websvn/filedetails.php?repname=aduna&path=%2Forg.openrdf%2Falibaba%2Ftrunk%2Fobject-repository%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenrdf%2Frepository%2Fobject%2Fcomposition%2FClassTemplate.java&rev=9054&sc=1:
>
>    private void copyAnnotations(Method method, MethodInfo info)
>            throws NotFoundException {
>        copyMethodAnnotations(method, info);
>        copyParameterAnnotations(method, info);
>    }
>    private void copyMethodAnnotations(Method method, MethodInfo info)
>            throws NotFoundException {
>        String name = method.getName();
>        CtClass[] parameters = asCtClassArray(method.getParameterTypes());
>        for (CtMethod e : get(method.getDeclaringClass()).getMethods()) {
>            if (!equals(e, name, parameters))
>                continue;
>            MethodInfo em = e.getMethodInfo();
>            AnnotationsAttribute ai = (AnnotationsAttribute) em
>                    .getAttribute(AnnotationsAttribute.visibleTag);
>            if (ai == null)
>                continue;
>            if (ai.getAnnotations().length > 0) {
>                info.addAttribute(ai.copy(info.getConstPool(),
> Collections.EMPTY_MAP));
>                break;
>            }
>        }
>    }
>    private void copyParameterAnnotations(Method method, MethodInfo info)
>            throws NotFoundException {
>        String name = method.getName();
>        CtClass[] parameters = asCtClassArray(method.getParameterTypes());
>        for (CtMethod e : get(method.getDeclaringClass()).getMethods()) {
>            if (!equals(e, name, parameters))
>                continue;
>            MethodInfo em = e.getMethodInfo();
>            ParameterAnnotationsAttribute ai =
> (ParameterAnnotationsAttribute) em
>                    .getAttribute(ParameterAnnotationsAttribute.visibleTag);
>            if (ai == null)
>                continue;
>            Annotation[][] anns = ai.getAnnotations();
>            for (int i = 0, n = anns.length; i < n; i++) {
>                if (anns[i].length > 0) {
>                    info.addAttribute(ai.copy(info.getConstPool(),
> Collections.EMPTY_MAP));
>                    return;
>                }
>            }
>        }
>    }
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
> instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to