Eero,
This is actually quite easy to implement, and there are a couple ways to do so.


1) For the first, you will need a reference to the DefaultInstrumentManager. If you
are getting an InstrumentManager instance in one of your components, you can
usually do a cast.
From this you can call the locateInstrumentDescriptor() method, passing it the
fully qualified name of the Instrument you are interested in. This will return an
InstrumentDescriptorLocal instance to you which allows you to directly add and
remove CounterInstrumentListeners and ValueInstrumentListeners, as well as
create new samples.
From either the DefaultInsturmentManager or the InstrumentDescriptorLocal,
it is also possible to gain access to the descriptor of a sample. This will let you
register an InstrumentSampleListener. This may actually be what you want as
it will give you the values over a given sample period rather than the individual
raw data points.


2) Another option is to create an InstrumentManagerClient instance. This is
done by creating an instance of InstrumentManagerClientLocalImpl (or a subclass)
which takes a DefaultInstrumentManager as an argument. This new interface
provides access to a subset of what is available by directly accessing the
DefaultInstrumentManager so it is a better interface to provide to user code.
You can do the same kinds of things as can be done in option 1.


3) Create your own customer Connector by implementing the
InstrumentManagerConnector interface. This will allow you to specify your
class in the instruments configuration file. When the DefaultInstrumentManager
is initialized, it will create an instance of your connector and call its
setInstrumentManager method with itself as the argument.
The connector will be set up correctly if it implements LogEnabled,
Configureable, Initializable, Startable, or Disposable. So this method can be
quite useful. Notice that it does not include Serviceable as the
InstrumentManager is created at a point when the ServiceManager does not
yet exist.
Once your connector has the InstrumentManager instance, you can do what
you wish with it as in option #1.


4) A fourth option is to create a component which implements InstrumentManageable
with the setInstrumentManager method. When the container creates your
component, it will call this method and provide you with a reference to an
InstrumentManager. You will have to cast it to a DefaultInstrumentManager to be
able to make use of the above options. But it has the benefit of letting you also
make use of other components such as DataSourceComponents.


Let me know if you need more details.

Cheers,
Leif

Eero Kaukonen wrote:

Hello,

Is there any way to add custom Value- or CounterInstrumentListeners to
an InstrumentProxy without touching the contents of excalibur-instrument
or excalibur-instrument-manager packages? It seems to me that the only
way to add listeners is to use createInstrumentSample()- method in
InstrumentDescriptor and that it is not possible to create custom
samples with it, not even with a custom InstrumentClient.

The reason  why I am doing this is that  I would like to log every
single value of certain instruments to a db, to collect data of single
transactions in our app. Does anybody have some other ideas how this
could be done?  I'd prefer instruments, since the dataprocessing should
be done in a different client, not inside our app.

-eero




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Apache Excalibur Project -- URL: http://excalibur.apache.org/



Reply via email to