Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] set() capture oldvalue

Thank you for the suggestion.

There are two problems with using it in my case.
1) Requires double the mem usage for any entity in the system.
As I want to apply this aspect to all persistable entities to create audit logging, it seems a steep price to pay. The non-aspect way wouldn't require the extra
memory.

2) There are out-of-band actions that set the entity's state when it is reconstituted. There is a semantic difference between setting a field because the object is being moved from disk to memory, and setting a field value because something changed, and will be persisted
later.  I'm not advising those out-of-band actions.

Currently I seperate the two by having the persistance engine go directly to the field.
That is why I'm advising field sets that occur within  setter methods.
I could change it so the object has some state to keep track of wether or not it's being audited, and make the persistence stuff flip off that switch. but that would unnecessarily complicate the desgin relative to who it would have been done "the hard way" with out
apsects.

I was under the impression that a language level change would be in order.
I've started presenting my case to the user list first for exactly that reason. Beyond needing to verify that I wasn't just missing something, I need to get
support from users that such a change would have mutlitple benifits.



Tim Schafer
tschafer@xxxxxxxxxxx



----Original Message Follows----
From: Eric Bodden <eric@xxxxxxxxx>
Reply-To: aspectj-users@xxxxxxxxxxx
To: aspectj-users@xxxxxxxxxxx
Subject: RE: [aspectj-users] set() capture oldvalue
Date: Sat, 14 May 2005 09:58:14 +0200
MIME-Version: 1.0
Received: from mail.eclipse.org ([206.191.52.53]) by mc3-f4.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Sat, 14 May 2005 00:58:38 -0700 Received: from node3.eclipse.org (localhost [127.0.0.1])by mail.eclipse.org (Postfix) with ESMTP id 7F93FE817;Sat, 14 May 2005 04:00:59 -0400 (EDT) Received: from ms-dienst.rz.rwth-aachen.de (ms-2.rz.RWTH-Aachen.DE[134.130.3.131])by mail.eclipse.org (Postfix) with SMTP id 2DD526A0F2for <aspectj-users@xxxxxxxxxxx>; Sat, 14 May 2005 03:59:49 -0400 (EDT) Received: from r220-1 (r220-1.rz.RWTH-Aachen.DE [134.130.3.31])by ms-dienst.rz.rwth-aachen.de(iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004))with ESMTP id <0IGG00L1QZH831@xxxxxxxxxxxxxxxxxxxxxxxxxxx> foraspectj-users@xxxxxxxxxxx; Sat, 14 May 2005 09:58:20 +0200 (MEST) Received: from relay.rwth-aachen.de ([134.130.3.1])by r220-1 (MailMonitor for SMTP v1.2.2 ) ; Sat,14 May 2005 09:58:20 +0200 (MEST) Received: from lolo (0-068.vpn.RWTH-Aachen.DE [134.130.240.68])by relay.rwth-aachen.de (8.13.3/8.13.3/1) with ESMTP idj4E7wJ9u006547 for<aspectj-users@xxxxxxxxxxx>; Sat, 14 May 2005 09:58:19 +0200 (MEST)
X-Message-Info: GQXpnklFM/fIA+wARS3taHw67GDM8MPUID0rj5bR7ZQ=
X-Original-To: aspectj-users@xxxxxxxxxxx
Delivered-To: aspectj-users@xxxxxxxxxxx
Organization: RWTH Aachen University
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-Mailer: Microsoft Office Outlook, Build 11.0.6353
Thread-index: AcVX50GgyGMRdVjRTViak/ucy+HNvgAcfYug
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: 14 May 2005 07:58:39.0149 (UTC) FILETIME=[BD059DD0:01C5585A]


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tim Schafer wrote:
> 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?

Hi, Tim.

First of all I am not really sure if people would like to extend the
language that way because it would almost certainly mean introducing
new syntax with a new keywords and so forth and you usually need very
good reasons and (many!) very compelling use cases in order to get
this through.

On the other hand I think there is another solution to this problem:
As they said in 'Back to the future' think in 4 dimensions :-)
When the value gets set, this is captured by the set-pointcut. If
there *is* an old value, this must have been *set* before. So
whenever the set-pointcut matches, do the following in this order:

1.) See if there has previously an "old value" been stored by the
aspect.
2.) If so, execute your piece of code with this old value.
3.) Store the new value. It's going to be the next old value.

This could look like the following:

aspect Foo {


	private Object oldObject = null;

	after(Object newObject): set(* Object Bar.myField) {
		if(oldObject!=null) {
			doSometing(oldObject);
		}
		oldObject = newObject;
	}

}

Hope this makes sense.

Eric

<adv>
P.S. this is a fragement of ongoing work in the communicty about
"temporal pointcuts", which let you pick up exatcly such events. Feel
free to have a look at the tracematch-paper [1] by the abc-team or my
recent publications. Both our approaches provide a language construct
that lets you explicitly access this/target/args value *over time*.

[1] http://abc.comlab.ox.ac.uk/techreports#abc-2005-1
[2] http://bodden.de/publications
</adv>

- --
Eric Bodden
Chair I2 for Programming Languages and Program Analysis
RWTH Aachen University

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.3

iQA/AwUBQoWvlswiFCm7RlWCEQIU0gCfbGmV4qLiR/qjp1doi6AJC/RA/9wAoNkN
lLZxFVLyEMm8RH7QbwluQNkj
=CFi0
-----END PGP SIGNATURE-----


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




Back to the top