sofya.ed.semantic
Class ObjectFilter

java.lang.Object
  extended by sofya.ed.semantic.EventFilter
      extended by sofya.ed.semantic.EventSelectionFilter
          extended by sofya.ed.semantic.ObjectFilter
All Implemented Interfaces:
ChainedEventListener, ErrorRecorder, EventListener

public class ObjectFilter
extends EventSelectionFilter
implements ChainedEventListener, ErrorRecorder

Observable event filter which directs events to separate listeners for each object in the monitored system. Events which are not specific to individual object instances are discarded.

Version:
11/11/2005
Author:
Alex Kinneer

Nested Class Summary
 
Nested classes/interfaces inherited from interface sofya.ed.semantic.EventListener
EventListener.Arguments, EventListener.CallData, EventListener.ExceptionData, EventListener.FieldData, EventListener.MethodData, EventListener.MonitorData, EventListener.NewAllocationData, EventListener.ObjectData, EventListener.ThreadData, EventListener.ThreadStatus
 
Field Summary
 
Fields inherited from class sofya.ed.semantic.EventFilter
listenerCount, listeners
 
Constructor Summary
  ObjectFilter(ChainedEventListenerFactory celf)
          Creates a new object instance filter.
protected ObjectFilter(ChainedEventListenerFactory celf, ChainedEventListener parent, long streamId, java.lang.String streamName)
          Creates a new object instance filter attached to an existing filter chain.
 
Method Summary
 void constructorEnterEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.MethodData md)
          Notification that a constructor was entered.
 void constructorExitEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.MethodData md)
          Notification that a constructor was exited.
 java.lang.Exception getError()
          Gets the exception that put the filter in an error state.
static ChainedEventListenerFactory getFactory(ChainedEventListenerFactory celf)
          Gets a factory for producing instances of this class on demand.
 ChainedEventListener getParent()
          Gets the parent of this listener in the listener chain.
 long getStreamID()
          Gets the unique identifier associated with this event stream.
 java.lang.String getStreamName()
          Gets an informational name associated with this event stream.
 java.util.Map getTraceErrors()
          Returns any exceptions that were raised by listeners associated with individual objects.
 boolean inError()
          Reports whether the filter is in an error state.
 void instanceFieldAccessEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.FieldData fd)
          Notification that an instance field was read.
 void instanceFieldWriteEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.FieldData fd)
          Notification that an instance field was written.
 void monitorAcquireEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.MonitorData md)
          Notification that a thread has acquired a monitor.
 void monitorContendEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.MonitorData md)
          Notification that a thread is contending for a monitor.
 void monitorPreReleaseEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.MonitorData md)
          Notification that a thread is about to release a monitor.
 void monitorReleaseEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.MonitorData md)
          Notification that a thread has released a monitor.
 void rethrowError()
          Rethrows the originating exception if this filter is in an error state; does nothing if in a normal state.
 void systemExited()
          Notification that the system has terminated.
 void virtualMethodEnterEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.MethodData md)
          Notification that a virtual method was entered.
 void virtualMethodExitEvent(EventListener.ThreadData td, EventListener.ObjectData od, EventListener.MethodData md)
          Notification that a virtual method was exited.
 
Methods inherited from class sofya.ed.semantic.EventSelectionFilter
callReturnEvent, classPrepareEvent, constructorCallEvent, exceptionCatchEvent, exceptionThrowEvent, executionStarted, interfaceCallEvent, newAllocationEvent, staticCallEvent, staticFieldAccessEvent, staticFieldWriteEvent, staticInitializerEnterEvent, staticMethodEnterEvent, staticMethodExitEvent, systemStarted, threadDeathEvent, threadStartEvent, virtualCallEvent
 
Methods inherited from class sofya.ed.semantic.EventFilter
addEventListener, ensureCapacity, removeEventListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface sofya.ed.semantic.EventListener
callReturnEvent, classPrepareEvent, constructorCallEvent, exceptionCatchEvent, exceptionThrowEvent, executionStarted, interfaceCallEvent, newAllocationEvent, staticCallEvent, staticFieldAccessEvent, staticFieldWriteEvent, staticInitializerEnterEvent, staticMethodEnterEvent, staticMethodExitEvent, systemStarted, threadDeathEvent, threadStartEvent, virtualCallEvent
 

Constructor Detail

ObjectFilter

public ObjectFilter(ChainedEventListenerFactory celf)
Creates a new object instance filter.

Parameters:
celf - Listener factory used to create the listeners associated with observed objects.

ObjectFilter

protected ObjectFilter(ChainedEventListenerFactory celf,
                       ChainedEventListener parent,
                       long streamId,
                       java.lang.String streamName)
Creates a new object instance filter attached to an existing filter chain.

Parameters:
celf - Listener factory used to create the listeners associated with observed objects.
parent - Event listener from which this object filter will receive events.
streamId - Identifier assigned to this event stream by the factory creating this filter.
streamName - Informational name assigned to this event stream by the factory creating this filter.
Method Detail

getFactory

public static ChainedEventListenerFactory getFactory(ChainedEventListenerFactory celf)
Gets a factory for producing instances of this class on demand.

Parameters:
celf - Factory which the produced filters will use to generate listeners for their own filter streams.
Returns:
A listener factory which produces instances of this class to filter by object instance subsets of the events dispatched from the observed system.

getParent

public ChainedEventListener getParent()
Description copied from interface: ChainedEventListener
Gets the parent of this listener in the listener chain.

Specified by:
getParent in interface ChainedEventListener
Returns:
The event listener from which this listener receives events.

getStreamID

public long getStreamID()
Description copied from interface: ChainedEventListener
Gets the unique identifier associated with this event stream.

Specified by:
getStreamID in interface ChainedEventListener
Returns:
An value which should uniquely identify this event stream, typically derived from some characteristic of the filtering criteria being applied by the parent listener.

getStreamName

public java.lang.String getStreamName()
Description copied from interface: ChainedEventListener
Gets an informational name associated with this event stream.

Specified by:
getStreamName in interface ChainedEventListener
Returns:
A string which provides some description of the nature of the events handled by this string.

inError

public boolean inError()
Reports whether the filter is in an error state.

Note that errors raised while attempting to write to individual filter streams for each object will be stored for each such object if the listener associated with that object implements the ErrorRecorder interface. Those errors can be retrieved via getTraceErrors(). This method only reports whether the filter failed to instantiate a listener for a given object.

Specified by:
inError in interface ErrorRecorder
Returns:
true if an error has occurred while trying to create a listener.

rethrowError

public void rethrowError()
                  throws java.lang.Exception
Rethrows the originating exception if this filter is in an error state; does nothing if in a normal state.

Specified by:
rethrowError in interface ErrorRecorder
Throws:
java.lang.Exception - If an error has been raised while trying to create a listener for an object event stream.

getError

public java.lang.Exception getError()
Gets the exception that put the filter in an error state.

Specified by:
getError in interface ErrorRecorder
Returns:
The first unrecoverable exception that put the filter in an error state.

getTraceErrors

public java.util.Map getTraceErrors()
Returns any exceptions that were raised by listeners associated with individual objects.

Returns:
A map which relates objects to any exceptions raised while attempting to write events to their associated listeners. Map keys will be object IDs (as Longs), and values will be exception objects. No mapping will exist for an object for which the listener does not report any errors or does not implement the ErrorRecorder interface. Thus under ideal circumstances, if all attached listeners support error recording, the size of the returned map should be zero.

monitorContendEvent

public void monitorContendEvent(EventListener.ThreadData td,
                                EventListener.ObjectData od,
                                EventListener.MonitorData md)
Description copied from interface: EventListener
Notification that a thread is contending for a monitor.

Specified by:
monitorContendEvent in interface EventListener
Overrides:
monitorContendEvent in class EventSelectionFilter
Parameters:
td - Information about the thread which is contending for a monitor.
od - Information about the object which owns the monitor.
md - Information about the location of the monitor contention.

monitorAcquireEvent

public void monitorAcquireEvent(EventListener.ThreadData td,
                                EventListener.ObjectData od,
                                EventListener.MonitorData md)
Description copied from interface: EventListener
Notification that a thread has acquired a monitor.

Specified by:
monitorAcquireEvent in interface EventListener
Overrides:
monitorAcquireEvent in class EventSelectionFilter
Parameters:
td - Information about the thread which acquired a monitor.
od - Information about the object which owns the monitor.
md - Information about the location of the monitor acquisition.

monitorPreReleaseEvent

public void monitorPreReleaseEvent(EventListener.ThreadData td,
                                   EventListener.ObjectData od,
                                   EventListener.MonitorData md)
Description copied from interface: EventListener
Notification that a thread is about to release a monitor.

Specified by:
monitorPreReleaseEvent in interface EventListener
Overrides:
monitorPreReleaseEvent in class EventSelectionFilter
Parameters:
td - Information about the thread which is about to release a monitor.
od - Information about the object which owns the monitor.
md - Information about the location of the monitor about to be released event..

monitorReleaseEvent

public void monitorReleaseEvent(EventListener.ThreadData td,
                                EventListener.ObjectData od,
                                EventListener.MonitorData md)
Description copied from interface: EventListener
Notification that a thread has released a monitor.

Specified by:
monitorReleaseEvent in interface EventListener
Overrides:
monitorReleaseEvent in class EventSelectionFilter
Parameters:
td - Information about the thread which released a monitor.
od - Information about the object which owns the monitor.
md - Information about the location of the monitor release.

constructorEnterEvent

public void constructorEnterEvent(EventListener.ThreadData td,
                                  EventListener.ObjectData od,
                                  EventListener.MethodData md)
Description copied from interface: EventListener
Notification that a constructor was entered.

This is the first point during the object creation process at which the object can be uniquely identified.

Specified by:
constructorEnterEvent in interface EventListener
Overrides:
constructorEnterEvent in class EventSelectionFilter
Parameters:
td - Information about the thread executing the constructor.
od - Information about the object under construction. At the time of this event, only the object ID will be valid.
md - Information about the entered constructor.

constructorExitEvent

public void constructorExitEvent(EventListener.ThreadData td,
                                 EventListener.ObjectData od,
                                 EventListener.MethodData md)
Description copied from interface: EventListener
Notification that a constructor was exited.

NOTE: This event is raised only if the constructor completes normally. If a constructor throws an escaping exception, the object is not successfully created and thus further events related to the object are not possible.

Specified by:
constructorExitEvent in interface EventListener
Overrides:
constructorExitEvent in class EventSelectionFilter
Parameters:
td - Information about the thread executing the constructor.
od - Information about the object under construction. At the time of this event, only the object ID will be valid.
md - Information about the exited constructor.

instanceFieldAccessEvent

public void instanceFieldAccessEvent(EventListener.ThreadData td,
                                     EventListener.ObjectData od,
                                     EventListener.FieldData fd)
Description copied from interface: EventListener
Notification that an instance field was read.

Specified by:
instanceFieldAccessEvent in interface EventListener
Overrides:
instanceFieldAccessEvent in class EventSelectionFilter
Parameters:
td - Information about the thread in which the field access occurred.
od - Information about the object which owns the accessed field.
fd - Information about the accessed field.

instanceFieldWriteEvent

public void instanceFieldWriteEvent(EventListener.ThreadData td,
                                    EventListener.ObjectData od,
                                    EventListener.FieldData fd)
Description copied from interface: EventListener
Notification that an instance field was written.

Specified by:
instanceFieldWriteEvent in interface EventListener
Overrides:
instanceFieldWriteEvent in class EventSelectionFilter
Parameters:
td - Information about the thread in which the field write occurred.
od - Information about the object which owns the written field.
fd - Information about the written field.

virtualMethodEnterEvent

public void virtualMethodEnterEvent(EventListener.ThreadData td,
                                    EventListener.ObjectData od,
                                    EventListener.MethodData md)
Description copied from interface: EventListener
Notification that a virtual method was entered.

Specified by:
virtualMethodEnterEvent in interface EventListener
Overrides:
virtualMethodEnterEvent in class EventSelectionFilter
Parameters:
td - Information about the thread executing the method.
od - Information about the object on which the virtual method was called.
md - Information about the entered method.

virtualMethodExitEvent

public void virtualMethodExitEvent(EventListener.ThreadData td,
                                   EventListener.ObjectData od,
                                   EventListener.MethodData md)
Description copied from interface: EventListener
Notification that a virtual method was exited.

Specified by:
virtualMethodExitEvent in interface EventListener
Overrides:
virtualMethodExitEvent in class EventSelectionFilter
Parameters:
td - Information about the thread executing the method.
od - Information about the object on which the virtual method was called.
md - Information about the exited method.

systemExited

public void systemExited()
Description copied from interface: EventListener
Notification that the system has terminated.

Specified by:
systemExited in interface EventListener
Overrides:
systemExited in class EventSelectionFilter