Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] how to use Introduction in aspect

You are introducing a method to the point class. Consequently, you will have
to call it as a method on point, i.e.:

public class TestAspect{
    public static void main(String[] args){
        Point p;
       //--> How can I call the function setX() in aspect SetXValueAspect ?

        p.setX(1);  // Like this
    }
}

----- Original Message -----
From: "Ha Nguyen" <d.h.nguyen@xxxxxxxxxxxxxx>
To: <aspectj-users@xxxxxxxxxxx>
Sent: Saturday, January 25, 2003 6:13 PM
Subject: [aspectj-users] how to use Introduction in aspect


Could you help me to use "Introduction" ?
For example: I have class Point:

----------------------------------------------------------------------------
----

public class Point{
    int x,y;
}

----------------------------------------------------------------------------
----

I have an aspect to add the function to set the X value (just use as a
simple example):

----------------------------------------------------------------------------
----

public aspect SetXValueAspect{
    public void Point.setX(int val){
        x = val;
    }
}

----------------------------------------------------------------------------
----

How can I use this function out side the aspect ? Assume that I have a main
function outside the aspect:

----------------------------------------------------------------------------
----

public class TestAspect{
    public static void main(String[] args){
        Point p;
       --> How can I call the function setX() in aspect SetXValueAspect ?
    }
}

----------------------------------------------------------------------------
----

Thank you.
MH.



Back to the top