[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] pointcut on termination of java program

You can register to be called on VM shutdown:

  Runtime.getRuntime().addShutdownHook(..)

The VM closes all streams on shutdown anyway, but
an aspect might be useful to close the stream
when the application is shutdown, if the VM
stays up after the app completes.

Wes

On Sun, 14 Dec 2003 12:06:08 +0100
 Jan VAN BESIEN <Jan.VanBesien@xxxxxxxx> wrote:
> Hi
> 
> I would like to do something (close an OutputStream) when
> a program exits. In a single threaded application, it is
> possible to write:
> 
> private pointcut main () : execution (public static void
> main (String[]));
> after () : main () {
> 	//do something
> }
> 
> But when the application is multithreaded, the end of the
> main method does not imply the end of the program. I've
> been looking in "the java language specification" and
> other documents to see if there is (for example) some
> methode that's always called near the ending of an
> application... but I have not been able to find anything.
> 
> any ideas on a pointcut to capture the join point "the
> end of the program"?
> 
> thanks in advance,
> Jan Van Besien
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users