Hi all

I'm planning to implement pool events. This is already discussed on the dev list before but never implemented.
Pool events would create a nice extention mechanism without having to subclass.
A first use of these pool events would be logging for the dbcp component.


I will give a brief overview of what I'm planning to do so you can comment on naming, etc.
PoolListener: 4 success events & 4 failure events, all using the same PoolEvent object to store the event info.
The PoolEventSupport contains all the fire* methods.
These methods will be called from a wrapper class MonitoringObjectPool, thus avoiding having to modify all pool implementations.
(for the keyed pool a DelegatingKeyedObjectPool & MonitoringKeyedObjectPool)
And finally a PoolAdapter as a base class for the actual PoolEventLogger.


Now, I'm not happy with the name of the PoolAdapter, maybe it should be PoolEventAdapter and then PoolEventListener as well.

Comments?

Dirk

========================================================
public class PoolEvent extends EventObject {
public PoolEvent(ObjectPool source,Object key, Object pooledObject, Throwable error) {...}
... }


public class PoolEventSupport {
   public void fireObjectBorrowed(Object o) {...}
... }

public interface PoolListener extends EventListener {
   // Success events
   void objectBorrowed(PoolEvent event);
   void objectReturned(PoolEvent event);
   void objectAdded(PoolEvent event);
   void objectInvalidated(PoolEvent event);

   // Failure events
   void objectBorrowFailed(PoolEvent event);
   void objectReturnFailed(PoolEvent event);
   void objectAddFailed(PoolEvent event);
   void objectInvalidateFailed(PoolEvent event);
}

public class DelegatingObjectPool implements ObjectPool { ... }

public class MonitoringObjectPool extends DelegatingObjectPool {
   public Object borrowObject() throws Exception {
       try {
           Object o = super.borrowObject();
           eventSupport.fireObjectBorrowed(o);
           return o;
       }
       catch (Exception ex) {
           eventSupport.fireObjectBorrowFailed(null, ex);
           throw ex;
       }
   }

public abstract class PoolAdapter implements PoolListener { ...}

public class PoolEventLogger extends PoolAdapter { ... }




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to