[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Saving information from several pointcuts to an ObjectOutputStream


I'm trying to save information from several pointcut. More precise: I try to
catch method call that eventually will match some conditions, write it to a
class called DetailedSignature implements Serializable and save that
information in one place. 

As far as I - as aspectJ-newbie  - understood, I cannot open a file for the
whole life of an aspect, as there is no constructor. Therefore I tried to
use an ObjectOutputStream like this:

		pointcut methodWithReturnValue() : (execution(!void

			     after() returning(Object o) : methodWithReturnValue() { 
			    	 try {
			    		File testDataFile = new File("serializedTest.data");
				        FileOutputStream fout = new FileOutputStream(testDataFile,
				        ObjectOutputStream oos = new ObjectOutputStream(fout);
				        System.out.println("wrote detailedSignature
				     catch (Exception e) { e.printStackTrace(); }

The program runs fine and I actually can see the data I want in the file.
But when I try to read it, I get the exception:

java.io.StreamCorruptedException: invalid type code: AC

Now I searched and found that this always seems to happen when trying to
append to an ObjectOutputStream multiple times

Now I'm a bit at a loss. I was thinking of trying to write kind of
bruteforce the information to a text file and based on that read and
recreate the object manually, but that is certainly not very flexible. 

Does anyone know a way how to keep the outputstream open and pass it to
several matches of the pointcut? 
Or would you know a more elegant strategy of saving objects from within
several matches of a pointcut?

Thanks for help


(start of the file with captured method

Âà sr +org.test.serversimulation.DetailedSignatureËÃÂÂWâÃà 
Z isLiteralValueL allmodifierst Ljava/lang/String;L
callingobjectClassnameq ~ L callingobjectMethodNameq ~ L
callingobjectPackageq ~ L callingobjectPackageAndClassq ~ L
callingobjectParametersq ~ L 	modifierst Ljava/util/ArrayList;L 
parametersq ~ L returnValueClassq ~ L returnValuePackageq ~ L
returnValuePackageAndClassq ~ L signatureLongStringq ~ 
... all methods catched appear in the file.

View this message in context: http://www.nabble.com/Saving-information-from-several-pointcuts-to-an-ObjectOutputStream-tp22111630p22111630.html
Sent from the AspectJ - users mailing list archive at Nabble.com.