james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <dona...@apache.org>
Subject Update James to use SocketManager?
Date Sun, 04 Mar 2001 00:45:19 GMT
Hi,

I would like to update James to use ConnectionManager/SocketManager instead
of the SocketServer block. The SocketManager has been deprecated for a
while and has a number of issues which were fixed via
ConnectionManager/SocketManager. 

The old system was lossy in certain circumstances - it could leave
connections open on errors, or threads running loose. It also did not have
any notion of shuting down handlers (gracefully or tearing down). 

SocketServer was thus broken into two blocks ConnectionManager and
SocketManager. I just updated the Avalon CVS with a DefaultHandlerFactory
to help manage handlers/factorys to work with ConnectionManager block.
Using this allows either graceful shutdown or tear down of handlers via
methods

void disconnect( String name ) throws Exception;
void disconnect( String name, boolean tearDown ) throws Exception;

So the changes will mean that the changes will look something like.

class SMTPServer
{
   void init()
   {
      final int port = conf.getChild("port").getValueAsInt( 25 );
      final String bindTo = conf.getChild("bind").getValue( "" );
      
      ServerSocket serverSocket = null;

      if( bindTo.length() > 0 ) 
      {
         final InetAddress address = InetAddress.getByName( bindTo );
         serverSocket = m_socketManager.createServerSocket( port, 5,
address );
      }
      else
      {
         serverSocket = m_socketManager.createServerSocket( port );
      }

      final ConnectionFactory factory = 
          new DefaultConnectionFactory( SMTPHandler.class );
      m_connectionManager.connect( "SMTP", serverSocket, factory );
   }
}

And the above would act identically as it does now. The main reason for
this is because I am soon going to remove the code and don't want to end up
with gump sending a bazillion messages ;)

Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*


Mime
View raw message