Re: [aspectwerkz-user] obtaining the field type from a join point
Alexandru Popescu <[email protected]>
| Newsgroups | gmane.comp.java.aspectwerkz.user |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[quote Matt Ho::on 4/4/2005 4:39 PM]
> Sorry, I'm not being very clear.
>
> Suppose I have the following class:
>
> public class Foo {
> @Inject Bar bar;
> @Inject Hello world;
> @Inject Argle bargle;
> }
>
> I'm trying to write a AOP based dependency injector
> and would like to be able to extract the name of the
> class being tagged (Bar, Hello, and Argle) from within
> the advise method.
>
> Here's the pseudo-code.
>
> @Around("get(@Inject * *..*.*)")
> public void inject(...) {
> // 1. get the class of the field being annotated
> // i.e. Bar, Hello, or Argle
>
> // 2. lookup that class in an IoC registry
> // such as picoContainer
>
> // 3. return an instance of Bar, Hello, or Argle
> }
>
> What I'm having trouble with is I've tried all the
> methods from JoinPoint and StaticJoinPoint, but can't
> get the name of the annotated field's class.
>
> Thanks!
>
> M
>
>
>
>
> --- Alexandru Popescu <[email protected]> wrote:
> [quote Matt Ho::on 4/4/2005 5:09 AM]
>> Suppose I have the following class
>
>> public class Foo {
>> @TaggedField private Bar bar;
>> }
>
>> How would I write an advise so I could figure out
> the
>> type of field that I'm advising? In this case,
> Bar.
>> What I'm trying to do is write a PicoContainer
> like
>> dependency injector using AspectWerkz.
>
>> I have seen any references to this so far on the
> docs
>> or on the mailing list. Any thoughts on how this
>> could be done?
>
>> M
>
>
>
>
>
>> __________________________________
>> Do you Yahoo!?
>> Yahoo! Personals - Better first dates. More second
> dates.
>> http://personals.yahoo.com
>
>
> I am not sure I get your question. One thing I can
> think of is:
>
> set|get(@TaggedField * *..*.*) (restricted maybe to
> your packages).
>
> public void someAdvice(JointPoint jp) or public void
> someAdvice(StaticJoinPoint sjp) {
> }
>
> from JoinPoint/StaticJoinPoint you can extract the
> info you need.
>
>
> Another option would be to use args.
>
> --
> :alex |.::the_mindstorm::.|
>
>
This should definitely work: ((FieldSignature) sjp.getSignature()).getFieldType().
- --
:alex |.::the_mindstorm::.|
> __________________________________
> Yahoo! Messenger
> Show us what our next emoticon should look like. Join the fun.
> http://www.advision.webevents.yahoo.com/emoticontest
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)
iD8DBQFCUWRpOCPjdDT2FEURAgHgAKCxac6HMdBET+3jKpw7HFn/beuM1ACfejRv
ob7PWaMvM6BBUu5SpOQyq6g=
=7O8f
-----END PGP SIGNATURE-----