You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by jose luis sanchez <jo...@m-centric.com> on 2009/07/30 19:01:05 UTC

[T5] Create audit annotation

Hi all.

I'm trying to create an annotation for auditing methods in my 
application, in order to log to a file who is doing what.

The use of the annotation should be like this ...


@Audit(user=user, what=method)
private void storingAccount(.....)

where user and method should be parameters ...

But i can't find any info on how to make an annotation .. any idea ?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] Create audit annotation

Posted by jose luis sanchez <jo...@m-centric.com>.
Yeah,sure .. i was looking for Tapestry annotations howto .. and 
realized that are java5 related, not 5.

Lately, T5 is solving so many problems i'm start to think everything is 
related to it :-)

> Em Thu, 30 Jul 2009 14:01:05 -0300, jose luis sanchez 
> <jo...@m-centric.com> escreveu:
>
>> Hi all.
>
> Hi!
>
>> But i can't find any info on how to make an annotation .. any idea ?
>
> The first Google result for 'java annotation tutorial' is 
> http://java.sun.com/docs/books/tutorial/java/javaOO/annotations.html, 
> not very userful, but the second is quite good: 
> http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html. I 
> guess you need to improve your Google skills. :)
>
> To process the annotations in your services, take a look at service 
> advising: 
> http://tapestry.apache.org/tapestry5.1/tapestry-ioc/advice.html.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] Create audit annotation

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 30 Jul 2009 14:01:05 -0300, jose luis sanchez  
<jo...@m-centric.com> escreveu:

> Hi all.

Hi!

> But i can't find any info on how to make an annotation .. any idea ?

The first Google result for 'java annotation tutorial' is  
http://java.sun.com/docs/books/tutorial/java/javaOO/annotations.html, not  
very userful, but the second is quite good:  
http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html. I  
guess you need to improve your Google skills. :)

To process the annotations in your services, take a look at service  
advising: http://tapestry.apache.org/tapestry5.1/tapestry-ioc/advice.html.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] Create audit annotation

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Fri, 31 Jul 2009 04:56:08 -0300, jose luis sanchez  
<jo...@m-centric.com> escreveu:

> It should be like that .. but i believe the @Persist tag stores the  
> value of the field at runtime, so it should get the field value .. but  
> looking at the tapestry source code i can't get HOW to do it .. do you  
> think i'm right ?

Use a @SessionState field to hold your user object then use the  
ApplicationStateManager service to get or set its value.
@Persist fields are only available to the page they're declared.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] Create audit annotation

Posted by jose luis sanchez <jo...@m-centric.com>.
It should be like that .. but i believe the @Persist tag stores the 
value of the field at runtime, so it should get the field value .. but 
looking at the tapestry source code i can't get HOW to do it .. do you 
think i'm right ?
> Em Thu, 30 Jul 2009 15:34:33 -0300, jose luis sanchez 
> <jo...@m-centric.com> escreveu:
>
>> Is there any way i can send dynamic parameters to an annotation ?
>
> You just can't. They're computed at compiling time.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] Create audit annotation

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 30 Jul 2009 15:34:33 -0300, jose luis sanchez  
<jo...@m-centric.com> escreveu:

> Is there any way i can send dynamic parameters to an annotation ?

You just can't. They're computed at compiling time.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] Create audit annotation

Posted by jose luis sanchez <jo...@m-centric.com>.
Wow .. great .. thanks for your help ( everybody )

Now, i've doneit ... amazing how powerfull annotations are :-)

But ...

Is there any way i can send dynamic parameters to an annotation ?

private String userName;

Like @Audit (user="+userName+") or something like that ... or a way i 
can retrieve that information from inside the worker ..
> Annotations are just "special" java interfaces. They are providing some Meta data.
> Maybe you will want to have a look on : http://java.sun.com/docs/books/tutorial/java/javaOO/annotations.html
> http://www.oracle.com/technology/pub/articles/hunter_meta_2.html
>
> You should find some annotations declaration in tapestry-annotation jar sources.
>
>
> For what you are going to do you will probably have to create a Worker. That may appear to be a bit tricky at first glance.
> Have a look to ComponentClassTransformWorker and some of its implementation (PropertyWorker, InjectWorker and so on...)
>
> Also have a look to TapestryModule class and contributeComponentClassTransformWorker() method.
>
> -----Message d'origine-----
> De : jose luis sanchez [mailto:joseluis.sanchez@m-centric.com]
> Envoyé : jeudi 30 juillet 2009 19:01
> À : Tapestry users
> Objet : [T5] Create audit annotation
>
> Hi all.
>
> I'm trying to create an annotation for auditing methods in my
> application, in order to log to a file who is doing what.
>
> The use of the annotation should be like this ...
>
>
> @Audit(user=user, what=method)
> private void storingAccount(.....)
>
> where user and method should be parameters ...
>
> But i can't find any info on how to make an annotation .. any idea ?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
>
> Ce message et les pièces jointes sont confidentiels et réservés à l'usage exclusif de ses destinataires. Il peut également être protégé par le secret professionnel. Si vous recevez ce message par erreur, merci d'en avertir immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant être assurée sur Internet, la responsabilité du groupe Atos Origin ne pourra être recherchée quant au contenu de ce message. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne saurait être recherchée pour tout dommage résultant d'un virus transmis.
>
> This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos Origin group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>   



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: [T5] Create audit annotation

Posted by Komiwes Robin <ro...@atosorigin.com>.
Annotations are just "special" java interfaces. They are providing some Meta data.
Maybe you will want to have a look on : http://java.sun.com/docs/books/tutorial/java/javaOO/annotations.html
http://www.oracle.com/technology/pub/articles/hunter_meta_2.html

You should find some annotations declaration in tapestry-annotation jar sources.


For what you are going to do you will probably have to create a Worker. That may appear to be a bit tricky at first glance.
Have a look to ComponentClassTransformWorker and some of its implementation (PropertyWorker, InjectWorker and so on...)

Also have a look to TapestryModule class and contributeComponentClassTransformWorker() method.

-----Message d'origine-----
De : jose luis sanchez [mailto:joseluis.sanchez@m-centric.com]
Envoyé : jeudi 30 juillet 2009 19:01
À : Tapestry users
Objet : [T5] Create audit annotation

Hi all.

I'm trying to create an annotation for auditing methods in my
application, in order to log to a file who is doing what.

The use of the annotation should be like this ...


@Audit(user=user, what=method)
private void storingAccount(.....)

where user and method should be parameters ...

But i can't find any info on how to make an annotation .. any idea ?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org




Ce message et les pièces jointes sont confidentiels et réservés à l'usage exclusif de ses destinataires. Il peut également être protégé par le secret professionnel. Si vous recevez ce message par erreur, merci d'en avertir immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant être assurée sur Internet, la responsabilité du groupe Atos Origin ne pourra être recherchée quant au contenu de ce message. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne saurait être recherchée pour tout dommage résultant d'un virus transmis.

This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos Origin group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org