> > PS Can we also be allowed to run up more than one SPLAT without clashing
> > ports for the web service interface? I think Al wrote some code in JPCS
> > which could be used for allocating ports (and should be factored out of
> > JPCS).
>
>
> yes, that's certainly a change I need to make (for SoG too), but I don't
> think Al has committed those updates yet...
It's not really updates, and it's unrelated to the JPCS stuff really. You
just have to modify your SOAPServer startup to do something like this...
SOAPServer soapServer = SOAPServer.getInstance();
soapServer.setMonolith( dtask );
int startPort = 9000;
int usingPort = startPort;
for( int i = startPort; i < startPort+1000; i++ ) {
// check port
boolean open = true;
try {
Socket tempSocket = new Socket( "localhost", i );
tempSocket.close();
} catch (Exception any) {
// Fails if not already in use, which is good.
open = false;
}
if( !open) {
usingPort = i;
//System.out.println( "Using port " + usingPort );
break;
}
}
soapServer.setPortNumber( usingPort );
soapServer.start();
and write the port number out to a reasonably placed file, which I do
something like this...
protected static String writeContactFile( int port )
{
String cookie = null;
File contactFile = getConfigFile( "soaptest.remote" );
if ( contactFile != null ) {
try {
contactFile.createNewFile();
Runtime.getRuntime().exec( "chmod 600 " +
contactFile.getPath() );
}
catch (Exception e) {
// Do nothing, chmod can fail validly under Windows.
//e.printStackTrace();
}
// Add the information we want.
try {
PrintStream out =
new PrintStream( new FileOutputStream( contactFile ) );
InetAddress addr = InetAddress.getLocalHost();
String hexVal = Integer.toHexString((int)(Math.random()*12345));
cookie = hexVal + addr.hashCode();
out.println( addr.getHostName() + " " + port + " " + cookie );
}
catch (Exception e) {
// Do nothing
}
}
return cookie;
}
along with an authentication cookie (Peter, this is almost a carbon copy
of the routine you use in SPLAT for remote execution stuff).
Basically it's a ten minute fix to anything using a SOAP server. I don't
think my SOAPServer wrapper class is much different from Peter's. I could
have a look in a bit if you like...
Al.
|