Hi Lukas,

Let's assume a strategy is called for all sorts of behaviors of the
SQL processing. One thing that would be good (I am thinking of our
code base at work) would be to add client data so that we can relate
the notifications to some external objects.

In our code, we have an object which identifies the database, the
caller and the thread making the call. It would be good if we could do
something like:
factory.setClientData("CallerInfo", callerInfo);

and in the strategy:
PreparedStatement eventPrepareStart(Query query, PreparedStatement stmt) {
  // factory is referenced by the strategy implementation
  CallerInfo callerInfo = (CallerInfo)factory.getClientData("CallerInfo");
  // Do something with callerInfo.
}

In practice, when our code calls fetch() for example, we could do this:
try {
  factory.setClientData("CallerInfo", callerInfo);
  // Here call with fetch().
} finally {
  factory.removeClientData("CallerInfo");
}

It is a concept that is present for example in UI APIs. Swing has
"JComponent.putClientProperty(Object, Object)" and SWT has
"Widget.setData(String, Object)" which are very convenient to avoid
decoupling an object and related information/state.

Custom advanced debugging tools could present SQL-related info as well
as contextual info at the time of the call.

Cheers,
-Christopher

Reply via email to