A ComponentMonitor if injected into DefultPicoContainer allows for certain events to me monitored at a container level. We are idealogically opposed to a forced choice of loging framework. If you're hell bent on logging, chose from a ComponentMonitor imlementation below. For now though consider what events are monitored:

Return Values

Instantiating returns a Constructor. An implementor of ComponentMonitor can choose to return a different Constructor reference. This is one way that implementations can be replaced or decorated (AOP style) with additional/changed functionality.

noComponentFound returns an Object (default of null in most cases). An implementor can choose to return an instance instead. That instance should be of a type that makes sense to the component that was being sought. The getComponent(..) would have otherwise failed, but this hypothetical ComponentMonitor intercepted that failure and provided something that makes sense.

General rules

  1. ComponentMonitor can generally be chained together. Meaning you can use them in combination.
  2. Most have NullComponentMonitor (see below) as their end stop.
  3. Any method on ComponentMonitor is open for interpretation. That means they can throw exceptions as well as return different values, making them modify PicoContainer's behavior.

Logging or text-centric varieties of ComponentMonitor

Hopefully self explanatory:

NullComponentMonitor

This is PicoContainer's default ComponentMonitor. It generally fits the NullObject pattern, but it does add behavior. Specifically if it encounters a lifecycleInvocationFailed(..) method invocation, it throws a PicoLifecycleException in response. If you use something other than NullComponentMonitor (bear in mind the default 'end stop' for most others is also NullComponentMonitor) then you could change the way PicoContainer responds to components it cannot start, stop of dispose of.

LifecycleComponentMonitor

This ComponentMonitor stores lifecycle failures and rethrows them later if rethrowLifecycleFailuresException() is called.

Future work

Implementations that: