You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Donald Ball <ba...@webslingerZ.com> on 2001/04/04 10:48:56 UTC
question on trax serializers
hey guys, i was playing around with adding caching to c2, just of the
final output - i was going to profile it on my local box and see what sort
of performance increase (or decrease) it resulted in. my sort of take on
it was to modify ResourcePipeline and have it pass a ByteArrayOutputStream
to the serializer instead of the environment's OutputStream. fair enough,
but how do we know when the serializer is finished? i don't think it's
sufficient to have called generator.generate(), because the various
sitemap components might (almost certainly will) fire off threads to do
their jobs. so i wrote me a little OutputStream wrapper class to notify me
when OutputStream.close() is called:
package org.apache.cocoon.util;
import java.io.OutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
public class NotifyingOutputStream extends FilterOutputStream {
protected Object recipient;
protected boolean isClosed = false;
public NotifyingOutputStream (OutputStream output, Object recipient) {
super(output);
this.recipient = recipient;
}
public void close() throws IOException {
super.close();
isClosed = true;
recipient.notify();
}
public boolean isClosed() {
return isClosed;
}
}
and i wait() on the recipient Object in ResourcePipeline until the close()
method is called and i'm notified. seems simple enough, but the close()
method is never called. isn't it the job of the trax serializer to close
the OutputStream when it's finished?
- donald
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org
Re: question on trax serializers
Posted by Berin Loritsch <bl...@apache.org>.
Donald Ball wrote:
>
> hey guys, i was playing around with adding caching to c2, just of the
> final output - i was going to profile it on my local box and see what sort
> of performance increase (or decrease) it resulted in. my sort of take on
> it was to modify ResourcePipeline and have it pass a ByteArrayOutputStream
> to the serializer instead of the environment's OutputStream. fair enough,
> but how do we know when the serializer is finished? i don't think it's
> sufficient to have called generator.generate(), because the various
> sitemap components might (almost certainly will) fire off threads to do
> their jobs. so i wrote me a little OutputStream wrapper class to notify me
> when OutputStream.close() is called:
>
> package org.apache.cocoon.util;
>
> import java.io.OutputStream;
> import java.io.FilterOutputStream;
> import java.io.IOException;
>
> public class NotifyingOutputStream extends FilterOutputStream {
>
> protected Object recipient;
> protected boolean isClosed = false;
>
> public NotifyingOutputStream (OutputStream output, Object recipient) {
> super(output);
> this.recipient = recipient;
> }
>
> public void close() throws IOException {
> super.close();
> isClosed = true;
> recipient.notify();
> }
>
> public boolean isClosed() {
> return isClosed;
> }
>
> }
>
> and i wait() on the recipient Object in ResourcePipeline until the close()
> method is called and i'm notified. seems simple enough, but the close()
> method is never called. isn't it the job of the trax serializer to close
> the OutputStream when it's finished?
I think (practically) that we have the ServletEngine or CocoonServlet
close the output stream for us.
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org