Hi Rajal:

I'm not sure what you mean by your question, but here's a little info about handlers:

1) In general, you don't want to keep state in the Handler itself.
However, you can control things by selecting one of three "scopes"
for the handler in the WSDD - "per-request", "per-access", and
"singleton".  (Right now "per-request" doesn't work, alas - I'll
remedy that after 1.0 goes out).  You specify them like this:

 <handler name="Foo" type="my.class.Handler" scope="per-access"/>

By default, Handlers are singletons, and therefore you should get
exactly the same Handler object every time your Handler gets
used.  If you set the scope to "per-access", you'll end up with a
new one every time it gets accessed (i.e. every time a message
processing flow hits your Handler in a chain).  Singleton Handlers
(as most of them should be) must be thread safe.  Which brings
me to...

2) The much better way to deal with state information which has
to do with a particular request is to put it in the MessageContext:

public class MyHandler extends BasicHandler {
   public static final String START_PROP = "MyHandler.startTime";
   public static final String ELAPSED_PROP = "MyHandler.elapsedTime";

   public void invoke(MessageContext mc) throws Exception {
       // Here we are now
       long now = new Date().getTime();
       if (mc.getPastPivot()) {
            // We're on the response side, so the request code below
            // must have already run and left us a start time.
                long startTime = ((Long)mc.getProperty(START_PROP)).longValue();
            Long elapsedTime = new Long(now - startTime);
            // Save the elapsed time back to the MC so others can use it
            mc.setProperty(ELAPSED_PROP, elapsedTime);
       } else {
            // Request side - save now as the start time
            mc.setProperty(START_PROP, new Long(now));
       }
   }
}

Hope this helps a bit,
--Glen


> -----Original Message-----
> From: Rajal Shah [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 02, 2002 12:29 PM
> To: [EMAIL PROTECTED]
> Subject: RE: client-config.wsdd
> 
> 
> How would you do performance monitoring on the client side.. 
> using client-config.wsdd.. I was unable to invoke the same 
> handler for request and response to calculate response time. 
> Any ideas?
> 
> I've asked this question earlier too.
> --
> Rajal
> 
> 
> -----Original Message-----
> From: James Casey [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 02, 2002 6:29 AM
> To: [EMAIL PROTECTED]
> Subject: Re: client-config.wsdd
> 
> 
> Whenever you need to modify any aspect of the request or 
> response flow 
> on the client side, for instance to add a client side handler 
> that might 
> modify/monitor the request/response.  Examples include
> 
> * client side logging/debugging
> 
> * Performance moitoring
> 
> * adding authorization/ digital signatures.
> 
> etc...
> 
> j.
> --
> Jan-Olav Eide wrote:
> > Under what circumstances is such a configuration file 
> required on the client
> > side ? 
> > 
> > 
> 

Reply via email to