Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Handling Exception while accesing Instance variable

Hi Andy,
  Yes the get handler handles all the public methods access , but we have
lot of fields declare as objects and our test code try to access with out
calling the methods by using the field name 
   so if i have a object PlanMember has Person Object and has
IdentificationCode Which has the SSN 
  Now our test code has 
    SSN = planMember.person.identificationcode.ssn ;
    name = planmember.person.name;
Here we want to to set null and continue to next line so we can run the test
cases without fixing every problem;

For methods im using the
pointcut handle() : call( public *  com.lfg.edm..*.get*(..)); 
which will handle all the getXX exceptions and the below for field access .

Well now im able to do something like as below with FieldHandler pattern :


	pointcut handleObj() : get(com.lfg.edm.fileimport.domain..* *.*);
	Object around() : handleObj( ) {

		try {
		         return proceed();
		} catch (Exception e) {
			System.out.println(" Exception handled for field access
"+e.getMessage());
			e.printStackTrace();
		} finally {
			System.out.println(" in finally proceed handleObj ");
		}
		return null;
	}

it solves the problem for now :)

Thanks,
Vinodh



Andy Clement wrote:
> 
> Does the get pointcut not do what you want?
> 
>  pointcut handle() : call( public *  com.lfg.edm..*.get*(..)) ||
> get(public * com.lfg.edm..*.*);
> 
> Andy.
> 2008/7/13 vinodh subbiah <vinodhts@xxxxxxxxxxxxxx>:
>> Hi All,
>> Im using Aspect J 1.5 and I need to write a pointcut to handle exceptions
>> while accessing .
>> So i come up with a point cut like one below
>> pointcut handle() : call( public *  com.lfg.edm..*.get*(..));
>>
>> This one works fine if they call using the getter methods.
>>
>> Now if i have a method like
>> getX().getY().getZ();
>> All of these type of access are now handled with my pointcut
>> But can anyone help me to define the same pointcut when the user tries to
>> access the object like below
>>
>>   Policy policy =  x.y.z ;
>>   Assume all the fields are public and so you can access with x.y.z.
>>
>> Thanks for your help in advance
>>
>> Vinodh Subbiah,
>> 580 Laforet Street,Apt 14
>> Windsor N9C3G8
>> Canada
>> Ph 519-971-7847
>>
>>
>> _______________________________________________
>> 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/Handling-Exception-while-accesing-Instance-variable-tp18430058p18472608.html
Sent from the AspectJ - users mailing list archive at Nabble.com.



Back to the top