JGibson
JGibson

Reputation: 1

How to filter out Frames of several applications within the same JVM

I have an application manager that loads and runs application jars in a single JVM. It isolates each jar to its own classloader. The manager communicates with the children through sockets for data and configuration purposes. The trouble that I am having is that I want to be able to use the getFrames call within each application for geometry save/restore and it always returns all frames within the JVM for every application running in that JVM. Is there a way to filter the results per application? I tried filtering based on classloader but the Frames classloaders are always null.

Upvotes: 0

Views: 69

Answers (2)

Peter Lawrey
Peter Lawrey

Reputation: 533790

I assume getFrames() queries some global collection. The only way to isolate such a globally accessible library is to have each application load is own copy of the Frames library (so its not globally accessible) This makes it harder to call getFrames() ;)

Upvotes: 1

Aaron Digulla
Aaron Digulla

Reputation: 328770

Since you give only few details, it's hard to say what could be wrong. Some comments:

  1. It's generally not a good idea to run several Java apps in a single VM. Logging frameworks and DB drivers, for example, install global hooks in the VM so unloading them becomes impossible. Consider to run each app in its own VM. Use the system properties to determine the parameters which you need. Here is some code that should get you started.

  2. If running each app in their own VM isn't an option, how about talking to each app and make it "register" itself with the app server? Web servers use standardized listeners for this purpose. That way, apps could tell you which frames/config values to save.

  3. The classLoader property of a class can never be null - A class loader is the only way to create a Class instance in Java.

Upvotes: 1

Related Questions