[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
Re: [aspectj-users] AspectJ issue or ...
|
- From: "Andy Clement" <andrew.clement@xxxxxxxxx>
- Date: Tue, 1 Apr 2008 19:17:43 -0700
- Delivered-to: aspectj-users@eclipse.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=GQSYNUJok69GTBYho6RpGfdphXe3bnJrrs6Kmk6h0Ec=; b=Re51BPT7Evfu3CEQTVHMY/P3Ee7zsZZSzSPsHDCL34jP10l3Rug1UhAjCAjSP2UqmlYdzOzI6lzNAmnBz2U4CF5PjEIkUxvR7FBzG5j2zehSvnhDo50WqvPu+gLAuYFOLBXJOKY6t2VKASojuRGE3m6Zit4YD+k089lO9uzLNew=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=X+VxK3JLdd7/+StM0kn15yFsBu5H20vGtAr7JbBN0yLkZzlZ4aDHsoqgLc11K3nGV3PIP8DwQB4HOwdFKCv2c6AM3JVOrsqt37JRMhSHPYhLbKzCYtWqp1B0Yvf9d+WIgofQ1dg0FN/VPq5/7UgPJtotcJuvp1k6PiNqVqqaOHE=
There is an article here on caching:
http://www.aspectprogrammer.org/blogs/adrian/2004/06/implementing_ca_1.html
Something like this might work for you:
public privileged aspect WriteBack extends WritePolicy
perthis(writeMethodCalled(Object)) {
private ICache myCache;
pointcut writingMethodCalled(Object o):
(execution(@WritingMethod void *(*))) && // my methods in Aclass
(or somewhere else)
args(o);
void around(Object o): writingMethodCalled(o) {
// We need to find out the current cache
// myCache is the current cache
(...)
}
you will get a different cache instance for every different execution
of an @WritingMethod annotated method (that takes a single argument).
Andy
On 01/04/2008, joss <jonathan.clairembault@xxxxxxxxx> wrote:
> Hi all,
>
> I got an issue with AspectJ. Actually I have got 2 classes (Cache and
> Aclass) and 1 aspect (WriteBack).
> I'd like to advise methods in Aclass by declaring pointcuts in
> WriteBack, but I need to write the result of those functions in Cache.
> My issue is how can I recuperate my Cache in which I want to write to.
>
> here is an example :
>
> public privileged aspect WriteBack extends WritePolicy {
>
> pointcut writingMethodCalled(Object o):
> (execution(@WritingMethod void *(*))) && // my methods in Aclass
> (or somewhere else)
> args(o);
>
> void around(Object o): writingMethodCalled(o) {
> // We need to find out the current cache
> ICache currentCache = ; // HERE IS THE ISSUE
>
> (...)
> }
>
> public interface ICache<D> extends Iterable<IEntry<D>>{
> int getSize();
> int getMaxSize();
> // entries with the same tag are merely modified (Data)
> void putEntry(IEntry<D> e);
> IEntry<D> getEntry(Taggable tag);
> IEntry<D> getEntry(Object data);
> void removeEntry(IEntry<D> e);
> }
>
> I wondering if I use my aspect with the clause perthis(cacheCreation()),
> may I recuperate the Cache instance linked with this aspect ?
>
> Thanks in advance,
> Jonathan Clairembault
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>