logger.log( Level.WARNING, "EJOE server already running - will try a restart." );
stop();
}
_isShuttingDown = false;
ConnectionAcceptor acceptor = null;
ChannelRegistrar processors[] = new ChannelRegistrar[this._serverInfo.getTargetedConnectionProcessors()];
ServerSocketChannel channel = null;
try
{
channel = ServerSocketChannel.open();
channel.configureBlocking( false );
channel.socket().setReuseAddress( true );
InetSocketAddress address = new InetSocketAddress( _serverInfo.getInterface(), _serverInfo.getPort() );
channel.socket().bind( address, 1024 );
this._serverInfo.setHost( address.getHostName() + ':' + address.getPort() );
// this._connectionHeader.setChannel(channel);
for ( int i = 0; i < processors.length; i++ )
{
processors[i] = new CombinedConnectionProcessor( this._serverInfo );
((Thread) processors[i]).setDaemon( true );
}
acceptor = new ConnectionAcceptor( channel, processors );
//acceptor.setDaemon( true );
}
catch ( IOException e )
{
logger.log( Level.SEVERE, "!!! IOException occured !!! ", e );
IOUtil.closeQuiet( channel );
throw (e);
}
for ( int i = 0; i < processors.length; i++ )
{
((CombinedConnectionProcessor) processors[i]).start();
}
acceptor.start();
this._serverInfo.setServerRunning( true );
this._processors = processors;
this._acceptor = acceptor;
this._channel = channel;