Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Re: aspectj-users Digest, Vol 3, Issue 17

Hi,
 
I am new to AspectJ 1.5. Currently We are using AspectWerkz 2.0 with Weblogic Portal application, we are planning to use AspectJ 1.5 with aop.xml.
 
Please tell me how to use aop.xml with aspectj 1.5 and where I will find out resources for aop.xml.
 
I tried with "The AspectJTM 5 Development Kit Developer's Notebook" but unable to use aop.xml
 
Regards,
 
Raman

 
On 5/18/05, aspectj-users-request@xxxxxxxxxxx <aspectj-users-request@xxxxxxxxxxx > wrote:
Send aspectj-users mailing list submissions to
       aspectj-users@xxxxxxxxxxx

To subscribe or unsubscribe via the World Wide Web, visit
       https://dev.eclipse.org/mailman/listinfo/aspectj-users
or, via email, send a message with subject or body 'help' to
       aspectj-users-request@xxxxxxxxxxx

You can reach the person managing the list at
       aspectj-users-owner@xxxxxxxxxxx

When replying, please edit your Subject line so it is more specific
than "Re: Contents of aspectj-users digest..."

Today's Topics:

  1. AJDT 1.2.0RC1 released for Eclipse 3.0 (Matt Chapman)
  2. Marker Interface and Abstract Pointcut (Irum Godil)
  3. Marker Annotations (neil@xxxxxxxxxxxx)
  4. Re: How many AspectJ users?   (Adrian Colyer)
  5. Re: Marker Annotations (Adrian Colyer)
  6. Re: Marker Interface and Abstract Pointcut (Adrian Colyer)
  7. RE: set() capture oldvalue (Adrian Colyer)

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

Message: 1
Date: Tue, 17 May 2005 17:20:00 +0100
From: Matt Chapman <mchapman@xxxxxxxxxx>
Subject: [aspectj-users] AJDT 1.2.0RC1 released for Eclipse 3.0
To: aspectj-users@xxxxxxxxxxx
Message-ID: <pan.2005.05.17.16.19.54.402889@xxxxxxxxxx>
Content-Type: text/plain; charset=ISO-8859-1

The AJDT team are pleased to announce the first release candidate of AJDT
1.2.0 for Eclipse 3.0.

AJDT 1.2.0RC2 will follow in a week or two. It will then be declared
final if no serious issues are found within a further week. This should
result in an early June release for AJDT 1.2.0.

This release will be for Eclipse 3.0 only, although equivalent development
builds for Eclipse 3.1 will also be made available (currently supporting
3.1M6 - we will move up to the new 3.1M7 as soon as possible). A stable
AJDT for Eclipse 3.1 cannot be reached until after the final Eclipse 3.1
release, and also after the final release of AspectJ 5. AJDT 1.2.0 will
therefore only be made available as a stable release for Eclipse 3.0 ,
replacing AJDT 1.1.12 as the latest stable release.

As for 1.2.0RC1, this release contains a number of bug fixes since
1.2.0M3, plus the addition of a migration wizard, which will help you
upgrade workspaces that have been used with earlier versions of AJDT, such
as 1.1.12. There is also a new "Open AspectJ Type" dialog (available from
the Navigate menu and via Ctrl-Alt-T) which is similar to the regular
"Open Type" one, but includes aspects.

Please try out the migration wizard in particular, as well as the rest of
AJDT, and raise bugs as usual. With your help we can make AJDT 1.2.0 as
stable as possible.

See the AJDT download page for more information:

   http://www.eclipse.org/ajdt/download.html

The build identifier is "1.2.0.20050517150219". It should appear in the
update list if you currently have 1.2.0M3 installed and search for updates
to installed features.

Regards,

Matt + the rest of the AJDT team.

--
Matt Chapman
AJDT Development, http://www.eclipse.org/ajdt

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

Message: 2
Date: Tue, 17 May 2005 09:48:40 -0700 (PDT)
From: Irum Godil <softwarengineer2004@xxxxxxxxx>
Subject: [aspectj-users] Marker Interface and Abstract Pointcut
To: aspectj-users@xxxxxxxxxxx
Message-ID: <20050517164840.87988.qmail@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
Content-Type: text/plain; charset="us-ascii"

Hi,
I want a few of my classes to implement the same advice, so I created an aspect with a marker interface and an abstract pointcut as follows:

abstract public aspect SynchMethods {

         public interface Synch {}
         abstract pointcut synchCall(Synch s);
...
}

Now, in a another aspect where I want to concretize the pointcut, I am doing:

declare parents: AbstractPublisher implements SynchMethods.Synch;

pointcut synchCall(AbstractPublisher a) : target(a) && execution(public void addSubscriber(TransactionSubscriber))

However, I keep getting the following compile error:

can't override pointcut aspects.multithread.weave.SynchMethods.synchCall (aspects.multithread.weave.SynchMethods$Synch) with pointcut aspects.multithread.weave.ThreadAbstractPublisher.synchCall(org.prevayler.implementation.publishing.AbstractPublisher) parameter types don't match ThreadAbstractPublisher.aj

I am not sure why I am getting this error when I have declared AbstractPublisher to implement the Synch interface. Any help on this will be greatly appreciated.

Thanks.
Sincerely,
Irum Godil.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://eclipse.org/pipermail/aspectj-users/attachments/20050517/e560bf20/attachment.html

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

Message: 3
Date: Tue, 17 May 2005 12:26:57 -0700 (PDT)
From: neil@xxxxxxxxxxxx
Subject: [aspectj-users] Marker Annotations
To: aspectj-users@xxxxxxxxxxx
Message-ID: <43720.127.0.0.11.1116358017.squirrel@xxxxxxxxxxxxxxxx>
Content-Type: text/plain;charset=iso-8859-1

I've been using AspectJ a bit and I've got a question that is way outside
of my experience and was wondering if someone could help.

I would like to use a Market Annotation on fields in a class to generate
an equals method. Something like:

public class Rubble {
  @Equal
  private Long fred;

  @Equal
  private String wilma;
}

would build a new:

  public boolean equals(Object value) {
      Rubble rubbleValue = (Rubble)value;
      return (fred.equals(rubbleValue.fred &&
                     wilma.equals(rubbleValue.wilma));
}

Obviously the example equals method logic isn't complete.  I would
probably use EqualsBuilder or something to make it easier.

TIA

Neil Hart

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

Message: 4
Date: Wed, 18 May 2005 08:55:16 +0100
From: Adrian Colyer < adrian_colyer@xxxxxxxxxx>
Subject: Re: [aspectj-users] How many AspectJ users?
To: aspectj-users@xxxxxxxxxxx
Message-ID:
       < OFAFBAE94F.A405EBA9-ON80257005.002ADFBD-80257005.002B83A5@xxxxxxxxxx>
Content-Type: text/plain; charset="ISO-8859-1"

I've been holding off on answering this as we have only just been able to
get full and accurate download statistics from eclipse.org and I wanted to
watch the data for a little while to be sure of the numbers. Since we have
only recently been able to track, I can't give you a histogram, but I can
tell you that:

* AspectJ/AJDT are currently running at 15-20,000 downloads per-month
between them.

During the period for which I have measurements, there where no new
releases or milestone builds put out, which I would expect to cause a
spike in the numbers.

This represents strong growth from the last period when there was data
available - which is when AspectJ was still run as a project out of PARC
in 2002.

Regards, Adrian.

-- Adrian
Adrian_Colyer@xxxxxxxxxx

André Dantas Rocha <ad-rocha@xxxxxxxxxx>
Sent by: aspectj-users-bounces@xxxxxxxxxxx
01/05/2005 00:07
Please respond to
aspectj-users@xxxxxxxxxxx

To
<aspectj-users@xxxxxxxxxxx >
cc

Subject
[aspectj-users] How many AspectJ users?

Hi,

Does anybody knows how many users is actually using AspectJ? (a
histogram?)

Thanks,

André_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users

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

Message: 5
Date: Wed, 18 May 2005 09:09:20 +0100
From: Adrian Colyer <adrian_colyer@xxxxxxxxxx>
Subject: Re: [aspectj-users] Marker Annotations
To: aspectj-users@xxxxxxxxxxx
Message-ID:
       <OF5D290212.A1A7B3FD-ON80257005.002C8557-80257005.002CCD35@xxxxxxxxxx >
Content-Type: text/plain; charset="US-ASCII"

Generation of  a method like this is not something that AspectJ can easily
help you with. You could write a generic equals method that uses
reflection to find out which fields have the annotation and compare them
(and then maybe use itds to declare that equals implementation on behalf
of the target types). Avoiding reflection though, I think the best
solution to this is probably to use something like APT:
http://java.sun.com/j2se/1.5.0/docs/guide/apt/

-- Adrian
Adrian_Colyer@xxxxxxxxxx

neil@xxxxxxxxxxxx
Sent by: aspectj-users-bounces@xxxxxxxxxxx
17/05/2005 20:26
Please respond to
aspectj-users@xxxxxxxxxxx

To
aspectj-users@xxxxxxxxxxx
cc

Subject
[aspectj-users] Marker Annotations

I've been using AspectJ a bit and I've got a question that is way outside
of my experience and was wondering if someone could help.

I would like to use a Market Annotation on fields in a class to generate
an equals method. Something like:

public class Rubble {
  @Equal
  private Long fred;

  @Equal
  private String wilma;
}

would build a new:

  public boolean equals(Object value) {
      Rubble rubbleValue = (Rubble)value;
      return (fred.equals(rubbleValue.fred &&
                     wilma.equals(rubbleValue.wilma));
}

Obviously the example equals method logic isn't complete.  I would
probably use EqualsBuilder or something to make it easier.

TIA

Neil Hart

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users

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

Message: 6
Date: Wed, 18 May 2005 09:23:16 +0100
From: Adrian Colyer <adrian_colyer@xxxxxxxxxx>
Subject: Re: [aspectj-users] Marker Interface and Abstract Pointcut
To: aspectj-users@xxxxxxxxxxx
Message-ID:
       <OFBD2AF153.4F236A8B-ON80257005.002D8222-80257005.002E13C3@xxxxxxxxxx>
Content-Type: text/plain; charset="US-ASCII"

AspectJ does not allow pointcut overriding, and your concrete synchCall
pointcut has a different signature to (overrides the) abstract synchCall
pointcut.  If you change the definition to:

pointcut synchCall(Synch a) : target(a) && target(AbstractPublisher) &&
execution(public void addSubscriber(TransactionSubscriber))

then things should work as expected. The target(a) _expression_ binds the
Synch object expected by the synchCall contract, the second target
_expression_ adds the extra condition that we're only interested in targets
which are AbstractPublishers. If you don't need that latter restriction,
just drop the second target _expression_.

-- Adrian
Adrian_Colyer@xxxxxxxxxx

Irum Godil <softwarengineer2004@xxxxxxxxx >
Sent by: aspectj-users-bounces@xxxxxxxxxxx
17/05/2005 17:48
Please respond to
aspectj-users@xxxxxxxxxxx

To
aspectj-users@xxxxxxxxxxx
cc

Subject
[aspectj-users] Marker Interface and Abstract Pointcut

Hi,
I want a few of my classes to implement the same advice, so I created an
aspect with a marker interface and an abstract pointcut as follows:

abstract public aspect SynchMethods {

         public interface Synch {}
         abstract pointcut synchCall(Synch s);
...
}

Now, in a another aspect where I want to concretize the pointcut, I am
doing:

declare parents: AbstractPublisher implements SynchMethods.Synch;

pointcut synchCall(AbstractPublisher a) : target(a) && execution(public
void addSubscriber(TransactionSubscriber))

However, I keep getting the following compile error:

can't override pointcut
aspects.multithread.weave.SynchMethods.synchCall(aspects.multithread.weave.SynchMethods$Synch )
with pointcut
aspects.multithread.weave.ThreadAbstractPublisher.synchCall(org.prevayler.implementation.publishing.AbstractPublisher)
parameter types don't match ThreadAbstractPublisher.aj
I am not sure why I am getting this error when I have declared
AbstractPublisher to implement the Synch interface. Any help on this will
be greatly appreciated.

Thanks.
Sincerely,
Irum Godil.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com _______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users

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

Message: 7
Date: Wed, 18 May 2005 09:41:55 +0100
From: Adrian Colyer <adrian_colyer@xxxxxxxxxx>
Subject: RE: [aspectj-users] set() capture oldvalue
To: aspectj-users@xxxxxxxxxxx
Message-ID:
       <OF71196B74.FEC7FAA0-ON80257005.002E6EC3-80257005.002FC8B9@xxxxxxxxxx>
Content-Type: text/plain; charset="US-ASCII"

This is a reasonable requirement. There are some potential complications
in the implementation to support after advice, and the interface to
provide access to the "before" value at a set join point is a little
awkward: it really has to go on the JoinPoint interface alongside getThis,
getTarget, and getArgs, even though it only applies to set join points.

If we did something like that you could write:

after(Object newValue) returning : set( * *) && args(newValue)  {   // the
pointcut would obviously be refined for a 'real' application...

Object oldValue =
thisJoinPoint.getOriginalFieldValueAtAFieldSetJoinPoint() ;  // would need
a better name...
if (!oldValue.equals(newValue) {
firePropertyChangeEvent(oldValue,newValue,thisJoinPoint.getSignature());
  }
}

Please raise an enhancement request on bugzilla if you think something
like this would be useful, and then I encourage others who have opinions
(for or against) to comment there.

-- Adrian
Adrian_Colyer@xxxxxxxxxx

"Nitzan Volman" <nitzan@xxxxxxxxxxx >
Sent by: aspectj-users-bounces@xxxxxxxxxxx
17/05/2005 15:34
Please respond to
aspectj-users@xxxxxxxxxxx

To
<aspectj-users@xxxxxxxxxxx>
cc

Subject
RE: [aspectj-users] set() capture oldvalue

Hi,

I encountered the same problem, and I think what Tim suggested is needed
in the language.
My use case is simple: I am trying to audit changes to an object by
monitoring field modifications, on each field modification (set operation)
I need to compare the previous and value of the field with the new value
to make sure the value really changed, no point in auditing fields that
are reset to the same value.
A typical scenario where this happens is when you submit web forms, most
of the values are the same but the "set" is called anyway.

I can think of several solutions for this use case that would not require
adding a feature to AspectJ... But doing this using AspectJ would be a
great enhancement

/Nitzan Volman

-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Tim Schafer
Sent: Monday, May 16, 2005 5:39 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] set() capture oldvalue

It's true in this particular application, the performance of reflection
won't
kill the application.
But it's just something that I feel is missing from the language. I wanted
to see what other use cases might exist. Performance could be a problem in
some cases.

Tim Schafer
tschafer@xxxxxxxxxxx

----Original Message Follows----
From: Matthew Webster <matthew_webster@xxxxxxxxxx>
Reply-To: aspectj-users@xxxxxxxxxxx
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] set() capture oldvalue
Date: Mon, 16 May 2005 07:50:11 +0100
MIME-Version: 1.0
Received: from mail.eclipse.org ([206.191.52.53]) by mc4-f24.hotmail.com
with Microsoft SMTPSVC( 6.0.3790.211); Sun, 15 May 2005 23:50:49 -0700
Received: from node3.eclipse.org (localhost [127.0.0.1])by
mail.eclipse.org
(Postfix) with ESMTP id E1D40CB4D;Mon, 16 May 2005 02:52:44 -0400 (EDT)
Received: from mtagate2.uk.ibm.com (mtagate2.uk.ibm.com
[195.212.29.135])by
mail.eclipse.org (Postfix) with SMTP id E5C276AC0Ffor
<aspectj-users@xxxxxxxxxxx >; Mon, 16 May 2005 02:51:44 -0400 (EDT)
Received: from
d06nrmr1407.portsmouth.uk.ibm.com(d06nrmr1407.portsmouth.uk.ibm.com
[ 9.149.38.185])by mtagate2.uk.ibm.com (8.12.10/8.12.10) with ESMTP id
j4G6oD4G320918for <aspectj-users@xxxxxxxxxxx>; Mon, 16 May 2005 06:50:13
GMT
Received: from d06av04.portsmouth.uk.ibm.com
(d06av04.portsmouth.uk.ibm.com[9.149.37.216])by
d06nrmr1407.portsmouth.uk.ibm.com (8.12.10/NCO/VER6.6) with ESMTP
idj4G6oDhG282280for <aspectj-users@xxxxxxxxxxx>; Mon, 16 May 2005 07:50:13

+0100
Received: from d06av04.portsmouth.uk.ibm.com (loopback [127.0.0.1])by
d06av04.portsmouth.uk.ibm.com ( 8.12.11/8.13.3) with ESMTP
idj4G6oDPY003034for <aspectj-users@xxxxxxxxxxx>; Mon, 16 May 2005 07:50:13

+0100
Received: from d06ml067.portsmouth.uk.ibm.com
(d06ml067.portsmouth.uk.ibm.com[9.149.38.140])by
d06av04.portsmouth.uk.ibm.com (8.12.11/8.12.11) with ESMTP
idj4G6oCZe003029for <aspectj-users@xxxxxxxxxxx>; Mon, 16 May 2005 07:50:12

+0100
X-Message-Info: GQXpnklFM/ejFGBEcP5COAwEw6lHHLtKPmpYmPhOgiU=
X-Original-To: aspectj-users@xxxxxxxxxxx
Delivered-To: aspectj-users@xxxxxxxxxxx
Sensitivity:
X-Mailer: Lotus Notes Release 6.5.3 September 14, 2004
X-MIMETrack: Serialize by Router on D06ML067/06/M/IBM(Release 6.53HF247
|January 6, 2005) at 16/05/2005 07:50:12
X-BeenThere: aspectj-users@xxxxxxxxxxx
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: aspectj-users.eclipse.org
List-Unsubscribe:
<https://dev.eclipse.org/mailman/listinfo/aspectj-users >,<
mailto:aspectj-users-request@xxxxxxxxxxx?subject=unsubscribe>
List-Archive: <http://eclipse.org/pipermail/aspectj-users >
List-Post: <mailto:aspectj-users@xxxxxxxxxxx>
List-Help: <mailto:aspectj-users-request@xxxxxxxxxxx ?subject=help>
List-Subscribe:
<https://dev.eclipse.org/mailman/listinfo/aspectj-users>,<
mailto: aspectj-users-request@xxxxxxxxxxx?subject=subscribe>
Errors-To: aspectj-users-bounces@xxxxxxxxxxx
Return-Path: aspectj-users-bounces@xxxxxxxxxxx
X-OriginalArrivalTime: 16 May 2005 06:50:50.0047 (UTC)
FILETIME=[98796CF0:01C559E3]

Tim,

If you have a concern about the performance of something measure it. Many
frameworks use performance. I don't believe it's impact on overall
application performance will be as bad as you think.

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/

"Tim Schafer" <tschafer@xxxxxxxxxxx>@eclipse.org on 13/05/2005 19:11:36

Please respond to aspectj-users@xxxxxxxxxxx

Sent by:    aspectj-users-bounces@xxxxxxxxxxx

To:     aspectj-users@xxxxxxxxxxx
cc:
Subject:    Re: [aspectj-users] set() capture oldvalue

That's exactly what I'm doing.
Using reflection.
I'm concerned about performance.
If I were using aspects I wouldn't use refelection in each setter to get
the old value. The aspect compiler should be able to do this work for me.
I believe it's a major defeciency that this isn't avaiblable. Are there
already plans to fix this? Should I file a bug?

Tim Schafer
tschafer@xxxxxxxxxxx

----Original Message Follows----
From: Matthew Webster <matthew_webster@xxxxxxxxxx>
Reply-To: aspectj-users@xxxxxxxxxxx
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] set() capture oldvalue
Date: Fri, 13 May 2005 16:14:30 +0100
MIME-Version: 1.0
Received: from mail.eclipse.org ([206.191.52.53]) by mc7-f35.hotmail.com
with Microsoft SMTPSVC( 6.0.3790.211); Fri, 13 May 2005 08:15:02 -0700
Received: from node3.eclipse.org (localhost [127.0.0.1])by
mail.eclipse.org

(Postfix) with ESMTP id 1DAB9E70F;Fri, 13 May 2005 11:17:14 -0400 (EDT)
Received: from mtagate4.uk.ibm.com (mtagate4.uk.ibm.com
[195.212.29.137])by

mail.eclipse.org (Postfix) with SMTP id 6D0276ABD5for
<aspectj-users@xxxxxxxxxxx >; Fri, 13 May 2005 11:16:05 -0400 (EDT)
Received: from
d06nrmr1407.portsmouth.uk.ibm.com(d06nrmr1407.portsmouth.uk.ibm.com
[ 9.149.38.185])by mtagate4.uk.ibm.com (8.12.10/8.12.10) with ESMTP id
j4DFEc78328870for <aspectj-users@xxxxxxxxxxx>; Fri, 13 May 2005 15:14:38
GMT
Received: from d06av02.portsmouth.uk.ibm.com
(d06av02.portsmouth.uk.ibm.com[9.149.37.228])by
d06nrmr1407.portsmouth.uk.ibm.com (8.12.10/NCO/VER6.6) with ESMTP
idj4DFEbN9284252for <aspectj-users@xxxxxxxxxxx>; Fri, 13 May 2005 16:14:37
+0100
Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1])by
d06av02.portsmouth.uk.ibm.com ( 8.12.11/8.13.3) with ESMTP
idj4DFEb7M026517for <aspectj-users@xxxxxxxxxxx>; Fri, 13 May 2005 16:14:37
+0100
Received: from d06ml067.portsmouth.uk.ibm.com
(d06ml067.portsmouth.uk.ibm.com[9.149.38.140])by
d06av02.portsmouth.uk.ibm.com (8.12.11/8.12.11) with ESMTP
idj4DFEbFm026512for <aspectj-users@xxxxxxxxxxx>; Fri, 13 May 2005 16:14:37
+0100
X-Message-Info: GQXpnklFM/deOXuyugSvCR2mxkvbZGrT7xa62XqVDbE=
X-Original-To: aspectj-users@xxxxxxxxxxx
Delivered-To: aspectj-users@xxxxxxxxxxx
Sensitivity:
X-Mailer: Lotus Notes Release 6.5.3 September 14, 2004
X-MIMETrack: Serialize by Router on D06ML067/06/M/IBM(Release 6.53HF247
|January 6, 2005) at 13/05/2005 16:14:37
X-BeenThere: aspectj-users@xxxxxxxxxxx
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: aspectj-users.eclipse.org
List-Unsubscribe: <https://dev.eclipse.org/mailman/listinfo/aspectj-users
>,<
mailto:aspectj-users-request@xxxxxxxxxxx?subject=unsubscribe>
List-Archive: <http://eclipse.org/pipermail/aspectj-users >
List-Post: <mailto:aspectj-users@xxxxxxxxxxx>
List-Help: <mailto:aspectj-users-request@xxxxxxxxxxx ?subject=help>
List-Subscribe: <https://dev.eclipse.org/mailman/listinfo/aspectj-users>,<
mailto: aspectj-users-request@xxxxxxxxxxx?subject=subscribe>
Errors-To: aspectj-users-bounces@xxxxxxxxxxx
Return-Path: aspectj-users-bounces@xxxxxxxxxxx
X-OriginalArrivalTime: 13 May 2005 15:15:03.0565 (UTC)
FILETIME=[89BCABD0:01C557CE]

Tim,

I'm sure there was a thread on either aspectj-users or aspectj-dev but I
can't find it. Bottom line is the existing field value is not a property
of the join point so you must get it directly. The simple examples below
shows you how to use reflection or direct access:

public class SomeClass {

       private int intField;

       public void setInt (int i) {
             intField = i;
       }
}

public aspect Aspect {

       pointcut fieldSet(int newValue) :
             set(* SomeClass+.*) && args(newValue)
             && withincode(* SomeClass+.set*(..))
             ;

       before (int newValue) : fieldSet (newValue) {

             Object oldValue = null;
             try {
                   Class clazz =
thisJoinPoint.getSignature().getDeclaringType();
                   String fieldName =
thisJoinPoint.getSignature().getName();
                   Field field = clazz.getDeclaredField(fieldName);
                   field.setAccessible(true);
                   oldValue = field.get(thisJoinPoint.getThis());
             }
             catch (Exception ex) {
                   ex.printStackTrace();
             }
             System.out.println("? beforeFieldSet() oldVaue=" + oldValue
+ ", newValue=" + newValue);
       }
}

public privileged aspect PrivilegedAspect {

       pointcut intFieldSet(SomeClass obj, int newValue) :
             set(* intField) && target(obj) && args(newValue)
             && withincode(* SomeClass+.set*(..))
             ;

       before (SomeClass obj, int newValue) : intFieldSet (obj,newValue)
{
             int oldValue = obj.intField;
             System.out.println("? beforeIntFieldSet() oldVaue=" +
oldValue
+ ", newValue=" + newValue);
       }

}

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/

"Tim Schafer" <tschafer@xxxxxxxxxxx>@ eclipse.org on 11/05/2005 21:47:44

Please respond to aspectj-users@xxxxxxxxxxx

Sent by:     aspectj-users-bounces@xxxxxxxxxxx

To:    aspectj-users@xxxxxxxxxxx
cc:
Subject:    [aspectj-users] set() capture oldvalue

I've used the following pointcut to capture all field modifications that
occur within a setter method.

pointcut fieldSet(Object newValue) : set(* SomeClass+.*) && args(newValue)
&& withincode(* SomeClass+.set*(..));

I can capture the new value, but I can't capture the old value without
resorting to reflection. In theory aspectJ could provide access to the old
value more statically. But aspectJ doesn't seem to support this. Or am I
missing something?

Tim Schafer
tschafer@xxxxxxxxxxx

_______________________________________________
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

_______________________________________________
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

_______________________________________________
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

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

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users

End of aspectj-users Digest, Vol 3, Issue 17
********************************************


Back to the top