-
1. Re: AOP to instrument classes on the fly ?
marc.fleury Jan 20, 2003 3:52 PM (in response to belaban)> Person p=new Person("Bela", 37);
> cache.put("bela", p);
> ...
> p.incrementAge();
> ...
> if(p.isModified()) {
> channel.replicate(p.toByteBuffer());
> p.setModified(false);
essentially incrementAge() is a field access modification and the modification is instrumented meaning it is indirected. The cache.put("bela", p) triggers
((AOP)p).getStack(addInterceptor(new CacheInterceptor(this));
the Cache Interceptor is notified of setters changes.
>
>
> The getModified() and setModified() methods are added
> to the class when the class is loaded. Possibly we
> also instrument the class with a method toStream()
> /fromStream, which provides efficient serialization,
> so my objects do not have to implement Serializable.
essentially you get notified from the interceptor you dynamically add when someone inserts the entry in your cache.
> Can this be done ?
sure.
> This would entail tracking state changes within the
> object.
exactly and you get notified.
> Can you guys at class loading time find out whether a
> method is write or read-only ? If it is write add
> some code which sets an internal boolean "modified".
Again better, you instrument it for modifications. We just create the indirection.
marcf