Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[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


Back to the top