On Friday 07 May 2004 07:33, Scott Brickner wrote:

If the QueueComponents are ultra-dumb, then I assume that they don't need to 
be (are not?) AF4 aware.

So I would then suggest an "CommunicationRouter" component that;
1. Smart enough.
2. Manages the LifeCycle of the Dumb components.
3. Has a dependee in form of the NIO component.

CommunicationRouter would have in the config something like;

<queues>
  <queue class="org.hedhman.niclas.queues.FtpQueue" >
    <port>21</port>
    <enabled>true</enabled>
  </queue>
  <queue class="org.hedhman.niclas.queues.SshQueue" >
    <port>443</port>
    <enabled>true</enabled>
  </queue>
  <queue class="org.hedhman.niclas.queues.HttpQueue" >
    <port>80</port>
    <enabled>true</enabled>
  </queue>
  <queue class="org.hedhman.niclas.queues.HttpQueue" >
    <port>8080</port>
    <enabled>true</enabled>
  </queue>
</queues>

IMHO, Making the Queues slightly 'smarter' so that they can register 
themselves with the NIOComponent seems like a reasonable trade-off;

public class FtpQueue 
    implements Serviceable, Disposable, CommunicationQueue
{
    private ConnectionManager m_ConnectionManager;

    /** @avalon.dependency type="org.hedhman.niclas.nio.ConnectionManager"
         key="ConnMan"
    */
    public void service( ServiceManager man ) throws ServiceException
    {
        m_ConnectionManager = (ConnectionManager) man.lookup( "ConnMan" );
        m_ConnectionManager.registerCommunicationQueue( this );
    }

    public void configure( Configuration conf ) 
        throws ConfigurationException
    {
        // Read in stuff like Port, Enabled and other config info.
    }

    public void dispose()
    {
        m_ConnectionManager.unregisterCommunicationQueue( this );
    }

    // CommunicationQueue  methods
    public int getPort()
    {
    }

    public boolean isEnabled()
    {
    }

    // and so on

    public void connectionEstablished( CommunicationEvent event )
    {
        // whatever
    }

    public void connectionLost( CommunicationEvent event )
    {
        // whatever
    }
}


IMHO, this gives you a more powerful and less coupled system.


Cheers
Niclas
-- 
+---------//-------------------+
|   http://www.bali.ac         |
|  http://niclas.hedhman.org   |
+------//----------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to