Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Invoke JNI and also capture 'quit' events?




On Dec 15, 2006, at 6:23 PM, Jamison Hope wrote:


4. Cleanly disconnect from the IPC system when the program quits.


Is there a way that I can capture the Quit message in the CFRunLoop, or invoke the JVM with the Carbon loop? (Or even better, does cmd-Q/Quit menu item generate a BSD signal I can capture before my program dies?)


It usually generates an AppleEvent you can capture, Apple provides the com.apple.eawt package for handling some of the events from java. Like...

		addApplicationListener(new ApplicationAdapter() {
			public void handleOpenFile(ApplicationEvent e) {
				System.out.println(e.getFilename() + "\nFEED ME ANOTHER!");
			}
			public void handleQuit(ApplicationEvent e) {
				System.out.println("URP!");
				System.exit(0);
			}
		});

[From http://users.spacestar.net/mikehall/javasrc.html#odoc DocumentMonster.dmg]

Java could tell your native code that it's time to disconnect I would think before the jvm itself is gone?
Or install a native event handler for the quit event. I'm not sure where I have any laying around but there should be many examples on the Apple site.


Unless this code doesn't receive AppleEvent's for some reason, Then, sorry, never mind, I am not exactly familiar with what you're doing.

Mike Hall        mikehall at spacestar dot net
http://www.spacestar.net/users/mikehall
http://sourceforge.net/projects/macnative



Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden

References: 
 >Invoke JNI and also capture 'quit' events? (From: Jamison Hope <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.