Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] getting Annotated field element

Hi Andy,

I had prb in accessing the Annotated field Attribute value . ie:

In my programe i have like this:
.....
@JndiInject(jndiName="java:/MySqlDS")
private MyService service1;
......
In Aspectj how could i retrive the value of jndiName?
This is my aspect to find the annoatated element:

pointcut dependencyJ() : get(@JndiInject * *) ;

     Object around() : dependencyJ(){
	System.out.println(" Aspecting for Annotated Field --  " );
	return "";
	}


Again i thank you for your help....



Andy Clement wrote:
> 
> I can't see any field-get join points in your program so your advice
> does not match.  I can see the field you want to match, but I can't
> see anywhere that accesses it - it is those places that would be
> matched by your aspect, for example change your println() to:
> 
> System.out.println(service);
> 
> and it will match. because 'service' is now being accessed.
> 
> Andy.
> 
> 2008/5/22 Ziaul Haque <ziaul.n@xxxxxxxxx>:
>> Hi i had a problem in accessing the Annotated field from AspectJ
>>
>> Here is my sample class:
>>
>> import javax.ejb.Remote;
>> import java.lang.annotation.*;
>> import javax.ejb.EJB;
>>
>> @Remote(MyAccount.class)
>>
>> public class MyAccountBean implements MyAccount
>> {
>>        @EJB(beanName="MyJndi")
>>        private MyService service;
>>        public void sayHelloFromAccountBean(){
>>        System.out.println("Say Hello");
>>        }
>> }
>> And the Aspect for this is :
>>
>> import javax.ejb.EJB;
>> import javax.naming.Context;
>> public aspect FiledAspect {
>>
>> String around(EJB annotation) : get(@EJB * * *) &&
>> @annotation(annotation) {
>> System.out.println("********** Finded Annotated Ellement ");
>> return "";
>>    }
>>
>> }
>> When i compiled using ajc as : ajc -1.5 MyAccountBean.java FieldAspect.aj
>> I'm getting a warning as "advice defined in FiledAspect has not been
>> applied
>> [Xlint:adviceDidNotMatch] ".
>> So how to get the Annotated filed "@EJB" .
>> Thanx in advance.
>> _______________________________________________
>> aspectj-users mailing list
>> aspectj-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 

-- 
View this message in context: http://www.nabble.com/getting-Annotated-field-element-tp17418365p17419063.html
Sent from the AspectJ - users mailing list archive at Nabble.com.



Back to the top