Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Saving data at program termination


I don't see anywhere in your code where data is initialized. Have you checked whether the before advice is being called and the shutdown hook registered? The after advice is redundant, just put the logic in the run() method of the hook.

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/



"Darkemon" <darkemon@xxxxxxxx>
Sent by: aspectj-users-bounces@xxxxxxxxxxx

09/12/2006 14:15

Please respond to
aspectj-users@xxxxxxxxxxx

To
aspectj-users@xxxxxxxxxxx
cc
Subject
[aspectj-users] Saving data at program termination





Hi,
I would like to advise a program termination to write (or show) collected data in a file when the program terminate. So that, the target program have finished all its method executions and not only that executed inside the main. I'am referring at application with threads or gui.

I tried to use an execution pointcut on a generic ShutdownThread.run() method and write data with a after advice like that below, but when save data there is an "Exception in thread "Thread-0" java.lang.NullPointerException".  I think that the "data" object life end out the main... but how can i save the data in this way?



aspect MyAspect
{
     DataStructure data; // this collected information on method executions of weaved target program

     pointcut mainExec() : execution(* *.main(..));
     

     before() : mainExec()
     {
          Runtime.getRuntime().addShutdownHook(new ShutdownThread());  
     }


     after() : execution(void ShutdownThread.run())
     {

            data.write(); // where is my data!?
            ...
     }
}

Iscriviti gratuitamente e ricevi una lista di 20 single della tua regione.Meetic.it_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top