[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Modifying constructors
|
Hello,
I am fairly new to AspectJ and am stuck at a point and would really appreciate your help.
I am trying a simple program in which I have a constructor method to create a "Car" object.
Example of the constructor:
public Car(String Type, int ModelYear)
{
my_Type = Type;
my_ModelYear = ModelYear;
}
What I am trying to do is that anytime this constructor is called, I would like to create a Car object but with different attributes instead of the original constructor:
public Car(String Type, String Color, int ModelYear)
{
my_Type = Type;
my_Color = Color;
my_ModelYear = ModelYear;
}
For this I createad the following pointcut and advice:
pointcut CarConstructor()
: execution(Car.new(..));
around(): CarConstructor()
{
Car(String Type, String Color, int ModelYear);
}
String my_Type, my_Color;
int my_ModelYear;
public void Car(String Type, String Color, int Model)
{
my_Type = Type;
my_Color = Color;
my_ModelYear = ModelYear;
}
Should I be capturing the arguements from the original constructor and send them to the new constructor along with the exta parameter "Color" or can this be achieved with a simpler approach?
Thanks!
Sarthak