Jamison Hope wrote:
>I'm writing a program which needs to do the following things:
>
>1. Open a connection to a message-passing system which communicates via
>SysV IPC.
>2. Invoke a JVM and instantiate some GUI objects (i.e. the AWT not-on-
>mail-thread rule applies).
>3. Listen for messages on IPC, and convert them into appropriate Java
>method calls (and do them).
>4. Cleanly disconnect from the IPC system when the program quits.
>
>I started with the simpleJavaLauncher sample program and have something
>which performs requirements 1-3. However, it does not disconnect on exit.
Why doe you need to use the JNI Invocation API? Why can't you write a
plain ordinary JNI library that interfaces to SysV IPC, then run your app
with the normal 'java' command or JavaApplicationStub?
Exactly what do you mean by "SysV IPC"? If it's just signals, that's not
hard to accomodate. I wrote a queued signal receiver in JNI for my open
source Suite/P Toolkit:
<http://www.amug.org/~glguerin/sw/#suitep>
I thought about adding support for the shm, sem, and msg functions, too,
but there didn't seem to be much demand for that kind of thing at the time,
and I had my own ax to grind for Suite/P, which didn't benefit from shm*(),
sem*(), etc.
Another possibility is to write a C/C++ helper tool that runs in another
process, which your Java app then exec()'s.
The helper is the recipient and sender of IPC communication, and it then
communicates with its parent process wia stdin, stdout, stderr, which are
all piped to the parent Java process. I've looked at this a few times,
too, and even did a simple version for catching signals sent from any user
(I exec'ed one child process for each user, changing uid to that user,
while the parent Java process remained root-owned). This is the Adapter
design pattern, or maybe Facade, written at an inter-process scale.
None of the above involved using the Invocation API, writing a launcher, or
knowing anything about main-thread rules. Except for the callback into the
JVM for receiving signals in the same process, it was pretty easy code, too.
-- GG
_______________________________________________
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