int portNumber = -1;
try {
portNumber = Integer.parseInt(System.getProperty("prose.port","UNDEFINED"));
}
catch (NumberFormatException noPortWasSpecified) {
throw new SystemStartupException("To use prose Remotely please specify the 'prose.port' property");
}
try {
// create, and export the objects.
activeInstance = new RemoteAspectManagerImpl(true);
activeInstanceRef = UnicastRemoteObject.exportObject(activeInstance);
testInstance = new RemoteAspectManagerImpl(false);
testInstanceRef = UnicastRemoteObject.exportObject(testInstance);
listener = new ServerSocket(portNumber);
Thread worker = new Thread() {
public void run() {
while (systemUp) {
try {
Socket s = listener.accept();
ObjectOutputStream objOut = new ObjectOutputStream(s.getOutputStream());
objOut.writeObject(activeInstanceRef);
objOut.writeObject(testInstanceRef);
}
catch (Exception e) { e.printStackTrace(); }
}
}
};
worker.start();
}
catch (RemoteException e) {
e.printStackTrace();
throw new SystemStartupException("Cannot export RemoteAspectManager");
}
catch (java.io.IOException e) {
e.printStackTrace();
throw new SystemStartupException("Cannot start a listener socket on the given port");
}
}