public class ObserverFilter extends java.lang.Object implements MessageFilter
Observer to decide which messages to publish to
the web interface.
The filter is applied in the container, before serialization, and so a message rejected by it is never seen by any web client. It is deliberately an exclusion-oriented filter: it is meant to silence traffic that is known to be uninteresting, so that the cost of serializing it is never paid. Deciding which of the remaining messages to display is left to the web interface, which can do so retrospectively.
Regular expressions are matched using find() semantics, i.e., a
substring match is sufficient. Anchor with ^ and $ for an
exact match. A null or empty expression is ignored. An invalid expression is
logged and ignored, so that a typo in the web interface cannot break
observation.
The public fields are deliberately simple, so that this class can be populated directly from the JSON sent by the web interface.
| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
clazz
Regex that the message class name must match, null to allow all.
|
java.lang.String |
excludeClazz
Regex that the message class name must not match, null to allow all.
|
java.util.Set<java.lang.String> |
excludeEndpoints
Endpoint names whose messages are to be dropped.
|
| Constructor and Description |
|---|
ObserverFilter()
Creates a filter that publishes all messages.
|
| Modifier and Type | Method and Description |
|---|---|
ObserverFilter |
compile()
Compiles the regular expressions.
|
ObserverFilter |
exclude(java.util.Collection<java.lang.String> endpoints)
Sets the endpoints whose messages are to be dropped.
|
ObserverFilter |
exclude(java.lang.String... endpoints)
Sets the endpoints whose messages are to be dropped.
|
boolean |
matches(Message m)
Returns true if a message matches the criteria, false otherwise.
|
java.lang.String |
toString() |
public java.lang.String clazz
public java.lang.String excludeClazz
public java.util.Set<java.lang.String> excludeEndpoints
# prefix, as they are encoded on the wire.public ObserverFilter()
public ObserverFilter compile()
public ObserverFilter exclude(java.lang.String... endpoints)
endpoints - endpoint names, null or empty to drop nothing.public ObserverFilter exclude(java.util.Collection<java.lang.String> endpoints)
endpoints - endpoint names, null or empty to drop nothing.public boolean matches(Message m)
MessageFiltermatches in interface MessageFilterm - message to check.public java.lang.String toString()
toString in class java.lang.Object