I can't use a singleton (or a map since I have several instance of a
same class) since I want the two instances of the server to be in a
different state.
The only way to solve this I can come up with is:
Server server1 = new Server("localhost", somePort, "", null,
MyClass.classs);
Configurator.setStaticInstance(instance1);
server1.start();
// wait for it to start and therefore call getInstance...
Server server2 = new Server("localhost", someOtherPort, "", null,
MyClass.classs);
Configurator.setStaticInstance(instance2);
server2.start();
Since I'm writing a generic API, that solution would require some
synchronization and I would like to know if this is really necessary or
if there is a more elegant way of doing it.
Thanks,
Regards.
Ly William