pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marc Herbert <Marc.Herbert@continuent.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: about monitoring the input stream
Date: Thu, 14 Sep 2006 12:08:09 +0200
Message-ID: <khj4pvayd4m.fsf@meije.emic.fr> (raw)
References: <200609131809.55435.acardona@ini.phys.ethz.ch>

Albert Cardona <acardona@ini.phys.ethz.ch> writes:

> The idea is not to modify the driver one bit in benefit of uncontroversial 
> deployment of my application (TrakEM2 at 
> http://www.ini.unizh.ch/~acardona/trackem2.html ). If java was lisp I would 
> simply alter the register to replace the InputStream, but it isn't and/or I 
> don't know how to use reflection to that extent

Thanks to its reflection API, java is actually lisp. Just a bit less
convenient. This should do the trick:

      pg_input_field = PGStream.class.getDeclaredField("pg_input");

      pg_input_field.setAccessible(true);

      InputStream orig_stream = (InputStream) pg_input_field.get(pg_stream_to_hack);

      InputStream counting_stream = new CountingInputStream(orig_stream);

      pg_input_field.set(pg_stream_to_hack, counting_stream);



> (I don't know what would happen was I to replace the InputStream
> using reflection once a connection has been created).

As far as I understand the driver you _have to_ replace it after the
connection has been created. Just avoid using it before replace.







view thread (10+ messages)  latest in thread

Message-ID: <khj4pvayd4m.fsf@meije.emic.fr>
Permalink:  ../khj4pvayd4m.fsf@meije.emic.fr/
Also on:    postgresql.org/message-id/khj4pvayd4m.fsf@meije.emic.fr

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: Marc.Herbert@continuent.com
  Subject: Re: about monitoring the input stream
  In-Reply-To: <khj4pvayd4m.fsf@meije.emic.fr>
  References: <200609131809.55435.acardona@ini.phys.ethz.ch> <khj4pvayd4m.fsf@meije.emic.fr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox