JXTA

net.jxta.impl.util
Class EndpointServiceStatsFilter

java.lang.Object
  extended by net.jxta.impl.util.EndpointServiceStatsFilter
All Implemented Interfaces:
MessageFilterListener

public class EndpointServiceStatsFilter
extends Object
implements MessageFilterListener

Instances of this clas can be registered with an EndpointService to gather statistics about what kind of messages pass through it.

This class is not MT-safe, so make sure you plug it only into one endpoint service.

See Also:
EndpointService.addIncomingMessageFilterListener(net.jxta.endpoint.MessageFilterListener, java.lang.String, java.lang.String)

Field Summary
(package private)  Hashtable channelTrafficTable
           
(package private)  Hashtable destCountTable
           
(package private)  long lastMessageTime
           
(package private)  Hashtable sourceCountTable
           
 
Constructor Summary
EndpointServiceStatsFilter()
           
 
Method Summary
 Message filterMessage(Message msg, EndpointAddress source, EndpointAddress dest)
          This method is called by the EndpointService to give us a chance to look at the message before it is dispatched to any listeners.
 Enumeration getChannelNames()
           
 long getLastMessageTime()
          Get the time we last saw a message.
 long getMessageCountFrom(EndpointAddress addr)
          Get the number of messages received from a given address.
 long getMessageCountTo(EndpointAddress addr)
          Get the number of messages we've seen that were adderssed to a given address.
 long getTrafficOnChannel(String channel)
          Get the number of messages seen with a given message element namespace or full message element name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastMessageTime

long lastMessageTime

channelTrafficTable

Hashtable channelTrafficTable

sourceCountTable

Hashtable sourceCountTable

destCountTable

Hashtable destCountTable
Constructor Detail

EndpointServiceStatsFilter

public EndpointServiceStatsFilter()
Method Detail

filterMessage

public Message filterMessage(Message msg,
                             EndpointAddress source,
                             EndpointAddress dest)
This method is called by the EndpointService to give us a chance to look at the message before it is dispatched to any listeners.

Specified by:
filterMessage in interface MessageFilterListener
Parameters:
msg - Incoming message
source - Endpoint Address of the original source of the message
dest - Endpoint Address of the original destination of the message
Returns:
Message The potentially modified or alternate message. If null is returned then the message has been discarded.

getLastMessageTime

public long getLastMessageTime()
Get the time we last saw a message.

Returns:
time last message was received, in milliseconds, since Jan. 1, 1970.

getTrafficOnChannel

public long getTrafficOnChannel(String channel)
Get the number of messages seen with a given message element namespace or full message element name. (Both are referred to as "channel" here because filters and listeners are dispatched by the EndpointService based on message element namespaces or fully name.)


getChannelNames

public Enumeration getChannelNames()

getMessageCountFrom

public long getMessageCountFrom(EndpointAddress addr)
Get the number of messages received from a given address.


getMessageCountTo

public long getMessageCountTo(EndpointAddress addr)
Get the number of messages we've seen that were adderssed to a given address.


JXSE