You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Jonathan Hawkes <jh...@adsnm.com> on 2003/11/07 23:24:12 UTC

[newbie] Avalon, COP, SAX, SEDA, etc.

Hi all,

I'm fairly new to this Component Oriented Programming stuff, and I tend to overuse design principles when I first become aware of them.

I am taking on the task of building a messaging server using the java.nio.* non-blocking API and XML as the underlying communications protocol.  I thought that it would be cool to use SAX since it is an event-driven interface.  However, although SAX is an event driven API, XMLReader and InputSource define only synchronous operations.  This is unfortunate because it means that I will have to use a pool of multiple threads for my SAX parsing (unless I build my own parser implementation).  I would like to hide this implementation detail, however, behind a component interface.

This is where I get back to my relevant question.  Although I am familiar with interface/implementation programming practices, I am unfamiliar with "best-practice" approaches for defining COP component interfaces.  I have included my attempt below.  Please comment.


import java.nio.channels.Pipe;

import org.apache.excalibur.xml.sax.XMLConsumer;


public interface AsynchXMLProcessor {

    String ROLE = AsynchXMLProcessor.class.getName();

    Pipe.Sink getByteSink();

    void setSourceConsumer(XMLConsumer consumer);
    void setSourceErrorHandler(XMLErrorHandler errorHandler);
}


public interface XMLErrorHandler extends org.xml.sax.ErrorHandler {

    public void fatality(Throwable t);
}


One criticism I have for the AsynchXMLProcessor is that is not thread-safe and it does not pool well.  I would probably need a factory interface instead of looking up the processor directly from the ServiceManager.  Another thought is that I could change the interface as below.  However, this seems less flexible to me in terms of adding future features (eg. a DTDHandler).


public interface AsynchXMLProcessor {

    String ROLE = AsynchXMLProcessor.class.getName();

    Pipe.Sink getByteSink(XMLConsumer consumer, XMLErrorHandler errorHandler);
}



Thanks all!
Jonathan Hawkes

Re: [newbie] Avalon, COP, SAX, SEDA, etc.

Posted by Steven Harris <st...@kenamea.com>.
Hello,
While I am also a newbie to the avalon world I have implemented a 
message router before so I am familiar with some of
the issues you will run into. Anyway, one thing you may want to check 
out for parsing xml in an efficient manner is.
stax http://www.xml.com/pub/a/2003/09/17/stax.html
Hope this is helpful.


On Nov 7, 2003, at 2:24 PM, Jonathan Hawkes wrote:

> Hi all,
>
> I'm fairly new to this Component Oriented Programming stuff, and I 
> tend to overuse design principles when I first become aware of them.
>
> I am taking on the task of building a messaging server using the 
> java.nio.* non-blocking API and XML as the underlying communications 
> protocol.  I thought that it would be cool to use SAX since it is an 
> event-driven interface.  However, although SAX is an event driven API, 
> XMLReader and InputSource define only synchronous operations.  This is 
> unfortunate because it means that I will have to use a pool of 
> multiple threads for my SAX parsing (unless I build my own parser 
> implementation).  I would like to hide this implementation detail, 
> however, behind a component interface.
>
> This is where I get back to my relevant question.  Although I am 
> familiar with interface/implementation programming practices, I am 
> unfamiliar with "best-practice" approaches for defining COP component 
> interfaces.  I have included my attempt below.  Please comment.
>
>
> import java.nio.channels.Pipe;
>
> import org.apache.excalibur.xml.sax.XMLConsumer;
>
>
> public interface AsynchXMLProcessor {
>
>     String ROLE = AsynchXMLProcessor.class.getName();
>
>     Pipe.Sink getByteSink();
>
>     void setSourceConsumer(XMLConsumer consumer);
>     void setSourceErrorHandler(XMLErrorHandler errorHandler);
> }
>
>
> public interface XMLErrorHandler extends org.xml.sax.ErrorHandler {
>
>     public void fatality(Throwable t);
> }
>
>
> One criticism I have for the AsynchXMLProcessor is that is not 
> thread-safe and it does not pool well.  I would probably need a 
> factory interface instead of looking up the processor directly from 
> the ServiceManager.  Another thought is that I could change the 
> interface as below.  However, this seems less flexible to me in terms 
> of adding future features (eg. a DTDHandler).
>
>
> public interface AsynchXMLProcessor {
>
>     String ROLE = AsynchXMLProcessor.class.getName();
>
>     Pipe.Sink getByteSink(XMLConsumer consumer, XMLErrorHandler 
> errorHandler);
> }
>
>
>
> Thanks all!
> Jonathan Hawkes


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: [newbie] Avalon, COP, SAX, SEDA, etc.

Posted by Alexis Agahi <al...@users.sf.net>.
On Friday 07 November 2003 23:24, Jonathan Hawkes wrote:
> Hi all,
>
> I'm fairly new to this Component Oriented Programming stuff, and I tend to
> overuse design principles when I first become aware of them.
>
> I am taking on the task of building a messaging server using the java.nio.*
> non-blocking API and XML as the underlying communications protocol.  I
> thought that it would be cool to use SAX since it is an event-driven
> interface.  However, although SAX is an event driven API, XMLReader and
> InputSource define only synchronous operations.

I dont know if this could help, you can implement you own non blocking Input 
source or use xml pull parsing api 
http://www.extreme.indiana.edu/xgws/xsoap/xpp/
http://kxml.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org