> interface Decoder
> {
> Message decode( byte[] buf );
> }
> class DecoderStage extends AbstractStage
> {
> private Decoder m_decoder;
>
> public void DecoderSink( Decoder decoder )
> {
> m_decoder = decoder;
> }
>
> Object process( Object event )
> {
> EventAssert.assertOfType( event, InputEvent.class );
> InputEvent a_event = (InputEvent)event;
> byte[] l_buf = a_event.getBuffer() ;
> return m_decoder.decode( l_buf ) ;
> }
> }
>
> so the event handling and the services is decoupled. The disadvantage is
> probably in that you'll likely want a stage, source or sink for each
> service work interface. But OTOH you should be able to use the same
> stage for different service implementations.
>
> WDYT?
You know the more I think about it the more this is really a matter
of separating out the Subscriber implementation from the component
implementation. Here's how I would put it in my pub/sub terms:
interface Decoder
{
Message decode( byte[] buf );
}
class InputSubscriber extends AbstractSubscriber
implements InputSubscriber
{
private Decoder m_decoder ;
public InputSubscriber ( Decoder decoder )
{
m_decoder = decoder ;
}
public void inform( InputEvent a_event )
{
EventAssert.assertOfType( a_event, InputEvent.class );
InputEvent a_event = ( InputEvent ) a_event;
byte[] l_buf = a_event.getBuffer() ;
m_decoder.decode( l_buf ) ;
}
}
Ok maybe this is not going to work. I cannot return anything. It's
probably best just making your Decoder implementation also implement
the InputSubscriber interface but not do away with the raw decode()
functionality: meaning keep the method there for general use.
I guess I still need to think about this idea a bit more. Still
scratching the old noggin.
Alex
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]