Running Multiple Nodes inside a single JVM

Azubuko Obele <[email protected]> Tue, 20 Sep 2005 14:40:10 -0400
Newsgroups gmane.comp.java.jxta.user
Message-ID <[email protected]>
I have a "simple" problem but I'm finding it impossible to make it work. For 
testing purposes, I want to be able to run several JXTA nodes in the same 
JVM. (How on earth do other people solve this problem by the way? Does 
everybody have arrays of machines they use for testing? Ant scripts? I'd 
think it would be a very common problem.) Ideally, I'd need to support 2-20 
nodes inside a single JVM that I can easily start and stop.

After speaking with bondolo, it seems I need to do the following:

1) Change the JXTA_HOME system property before I start each node.

2) Run each node inside its own ClassLoader. For example use a class like 
http://bench.jxta.org/source/browse/bench/performance/src/net/java/bench/load/PeerClassLoader.javathis
... but it's not clear HOW JXTA gets it's classloader. Do I just have
to change the thread context classloader before calling newNetPeerGroup() ?

3) Change the ports used by each Node in it's Profile -- how? It's not clear 
at all how to do this.

A little help please? Once I figure this out I'll gladly throw something on 
the wiki so others can set up their own jxta unit testing environment.