Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] record/replay "Input Methods"... what about Swing

Hi

I have implemented a record/replay application in AspectJ that is based on the principle to record everything "non deterministic" (with advice around particular "input methods") and to replay it by returning those recorded values for those methods (again with around advice).

That means I have an aspect RecordInput:

---- RecordInput ----
public aspect RecordInput {
	
	private XMLTracer tracer = new XMLTracer ("trace.xml");
	
	Object around () : InputPointcuts.providesInput () {
		Object input = proceed ();
		tracer.logJoinPoint (thisJoinPoint, input);
		return input;
	}
}
---- RecordInput ----

(XMLTracer takes care of the serialization to XML)

And another aspect for replaying:

---- ReplayInput ----
public aspect ReplayInput {
	
	private InputProvider ip = new InputProvider ("trace.xml");
	
	Object around () : InputPointcuts.providesInput () {
		Object input = ip.provideNextInput (thisJoinPoint);
		return input;
	}
}
---- ReplayInput ----

(InputProvider takes care of providing the previously serialized data).

You can see that I use a pointcut "InputPointcuts.providesInput()". The class InputPointcuts contains a set of pointcuts for what I call "input methods". Those methods are methods with a non deterministic return value, for example "java.io.Reader.read()", "Random.nextInt()", etc.

Most of them are "non deterministic" because their return values come from user input. That's why I call them "input methods".

This works fine for simple applications that use the classes Reader, InputStream, Random, ...

I would like to use this idea for recording and replaying every Java application (that uses classes from the standard Java API for "input"), even Swing applications.

I was wondering if anyone had some ideas of how to extend this to (for example) Swing. Swing is completely made out of Java beans, so I might record the arguments from every setter method. Or maybe I should record every call to a methode from a class that implements "EventListener", or ...

thanks in advance,
Jan Van Besien

ps: thanks to Kris De Schutter for the "input methods" idea ;-)



Back to the top