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: [OT] JNI + Threads



Josef Henryson wrote:

>I do save the state by the session but the native library I use don't. My
>preference would be to pass on the session ID to the library that keeps the
>state based on the same session. But the developer of the library doesn't
>want to manage threads since it is very platform specific and they want the
>library to be as portable as possible between platforms.

What does the library use to represent state?  Is it some kind of ID,
pointer, struct, or what?

Whatever it is, you should create a composite object (a new class) that
holds two things:
  1) the session object from Tomcat.
  2) the ID or whatever from the library.

Then pass in either that object, or just the ID, when you call the native
functions.


Or create a Map with session objects as keys and native-ID objects as
values.  Key with session, get native-ID, pass to native code.

In a sense, your idea of keying off the current thread is already doing
that, except you're proposing to use the thread as an implied key, not the
session object as an overt key.


The basic problem is mapping.  Given an A, what is its unique corresponding B.

  -- 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



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.