PDA

View Full Version : making tc server intercept object injected by @Resource



lunaspeed
Dec 8th, 2009, 12:21 AM
Hi
my application is written using Spring 2.5.6
however i dont use @Autowire, @Component,...etc
I use @Resource to do my DI.
when i run my application in tc server i can only see it intercepting my JDBC calls
and when i start tc server there is a log :


[TomcatAspectJWeavingClassLoader@1b15692] warning javax.* types are not being woven because the weaver option '-Xset:weaveJavaxPackages=true' has not been specified


i am new to the weaving idea
can someone tell me where and how this property should be set?
do i have to set it directly in the tc server? or in my AP?
and after this is set, will tc server intercept calls on the object injected by @Resource?

Thanx

sandrews
Dec 8th, 2009, 01:53 PM
The style of DI you utilize will not directly impact Spring Insight. However, the @Service annotation is used to advise your business objects and add frames to the trace. In the next release, we are going to make it easier to advise your own code, but for now, I would recommend annotation your injected objects with @Service. You do not need to turn on component scanning and can leave the rest of your configuration alone.

The message you are seeing on the log is normal and not indicative of an error.

lunaspeed
Dec 8th, 2009, 08:03 PM
Thanks for the reply

yes I have actually tried annotating my service with @Service and DAO with @Repository.
And it works wonders just like you said.

but maybe I don't understand the basic of @Component too well, so I am wondering if I add these annotations to my service and dao but still using @Resource for DI will there be any side effects or will the @Component annotations kick into effect at some point that i may not be aware of?
and is there any benefits, other than that it will be affected by tc server? or is it just a good practice in Spring?

Thanx

sandrews
Dec 9th, 2009, 08:46 AM
As long as you're not using component scanning, there should not be any side effects. Component scanning will automatically discover classes with the stereotype annotations and create new instances. This is something you have to specifically enable, so it should be safe to use the annotations on their own.

lunaspeed
Dec 10th, 2009, 08:38 PM
Thanks for the insight