You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Peter Donald <do...@apache.org> on 2001/03/04 01:45:19 UTC
Update James to use SocketManager?
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 |
*-----------------------------------------------------*
Re: Update James to use SocketManager?
Posted by Peter Donald <do...@apache.org>.
Another thing I am doing is unglobbing imports. The main reason for this is
that when I refactor code in Avalon it will be easier to refactor in James.
Explicit imports rather than globbing allows me to run a script over the
code base that auotmagically does it for me ;)
Another good reason is that it helps newbies to codebase locate classes
(rather than a search through all the globbed packages).
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 |
*-----------------------------------------------------*
Re: Update James to use SocketManager?
Posted by Charles Benett <Ch...@benett1.demon.co.uk>.
Delighted! I've been a bit busy recently, otherwise would have done it.
Charles
Peter Donald wrote:
>
> 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 |
> *-----------------------------------------------------*
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: james-dev-help@jakarta.apache.org
Re: Update James to use SocketManager?
Posted by Serge Knystautas <se...@lokitech.com>.
Sounds good Pete... appreciate whatever improvements you make to James.
Serge Knystautas
Loki Technologies
http://www.lokitech.com/
----- Original Message -----
From: "Peter Donald" <do...@apache.org>
To: <ja...@jakarta.apache.org>
Sent: Saturday, March 03, 2001 7:45 PM
Subject: Update James to use SocketManager?
> 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.
>
> ....