- From: Pasquale Di Feo <pasdif@netfly.it>
- Date: Tue, 16 Jul 1996 17:22:56 +0200
- To: Anselm Baird-Smith <abaird@w3.org>
- Cc: www-jigsaw@w3.org
At 09.58 16/07/96 +0500, you wrote:
>I am not sure I undertsand your problem. Yes, ingoing and outgoing are
>meant to be used together. However if you consume a stream at one
>point without replacing it (by using setStream), then whoever else
>wants to access the stream will get into troubles. Do you have any
>more details ?
OK, sorry. I don't understand becouse, but at this time the filter work fine.
Maybe are cache problems.
Following the code (base code from your sample)
package pdf.jigsaw.filters;
import w3c.jigsaw.http.*;
import w3c.jigsaw.resources.*;
import java.io.*;
import java.lang.*;
public class CountFilter extends ResourceFilter {
/**
* Attribute index - The counter attribute.
*/
protected static int ATTR_COUNTER = -1 ;
protected static int ATTR_FILE = -1 ;
static {
Attribute a = null ;
Class cls = null ;
try {
cls = Class.forName("pdf.jigsaw.filters.CountFilter") ;
} catch (Exception ex) {
ex.printStackTrace() ;
System.exit(1) ;
}
// Declare the counter attribute
a = new IntegerAttribute("counter" , new Integer(0) ,
Attribute.EDITABLE) ;
ATTR_COUNTER = AttributeRegistery.registerAttribute(cls, a) ;
a = new StringAttribute("file", "", Attribute.EDITABLE) ;
ATTR_FILE = AttributeRegistery.registerAttribute(cls, a) ;
}
/**
* We count all accesses, even the one that failed.
* @param request The request being processed.
*/
public synchronized int ingoingFilter(Request request) {
System.out.println("Valore del counter = " + getInt(ATTR_COUNTER, 0));
int i = getInt (ATTR_COUNTER, 0) ;
setInt(ATTR_COUNTER, i+1) ;
return CallOutgoing ;
}
/**
* Take the input stream, dump on the console and re-create a new stream
for reply.
*/
public Reply outgoingFilter(Request request, Reply reply) throws
HTTPException
{
InputStream in = reply.openStream() ;
if ( in == null )
{
System.out.println("InputStream == null");
return reply ;
}
DataInputStream ds = new DataInputStream(in);
if (ds == null)
{
System.out.println("DataInputStream == null");
return reply;
}
String strTmp;
StringBuffer buffer = new StringBuffer();
try
{
while ( (strTmp = ds.readLine()) != null)
{
System.out.println(strTmp);
buffer.append(strTmp);
}
}
catch (IOException e)
{
}
String strOut = buffer.toString();
StringBufferInputStream strIS = new StringBufferInputStream(strOut);
reply.setStream(strIS);
return reply;
}
}
>
> > Why the w3c.jigsaw.status.ExitStat kill only httpd and not the entire
> > application??
>
>It's the idea, yes. Basically you should be able to think of Jigsaw as
>a library too.
>
>Anselm.
It's right kill the process with ^C ??
Pasquale
Received on Tuesday, 16 July 1996 11:23:03 UTC