|
|||||||||
Atavism Version 2018.1 | AGIS API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectatavism.msgsys.Filter
atavism.server.messages.PerceptionFilter
public class PerceptionFilter
Match messages by message type and a list of target and subject OIDs.
One of the message types should be used by class PerceptionMessage
.
This filter should be used in conjunction with a PerceptionTrigger
.
Conceptually, the PerceptionFilter is a set of subject OIDs that match
SubjectMessages
and a set of target OIDs that
match TargetMessages
.
The subscriber maintains a set of target OIDs in the filter. Filter updates
are used to keep the producing agent filters in-sync. The producers
maintain a set of subject OIDs in the filter by inspecting all
PerceptionMessages
matched by the filter.
The filter's subject OIDs are a union of all the OIDs perceivable by
the filter's target OIDs.
The filter's subject OIDs are updated via a PerceptionTrigger
on the subscription. The producers only update their own copy of the
PerceptionFilter. The subscriber should also inspect
PerceptionMessages and use filter updates to keep the other
subscribers in-sync (those that don't publish PerceptionMessages).
PerceptionFilter supports FilterUpdate
with fields FIELD_TARGETS
and FIELD_SUBJECTS
. Operations FilterUpdate.OP_ADD
and FilterUpdate.OP_REMOVE
are supported.
Use MessageAgent.applyFilterUpdate()
to apply a filter update.
Nested Class Summary | |
---|---|
protected class |
PerceptionFilter.IntHolder
|
protected class |
PerceptionFilter.SubjectInfo
|
static class |
PerceptionFilter.TypedSubject
|
Field Summary | |
---|---|
static int |
FIELD_SUBJECTS
Subjects field id for FilterUpdate |
static int |
FIELD_TARGETS
Targets field id for FilterUpdate |
Constructor Summary | |
---|---|
PerceptionFilter()
|
|
PerceptionFilter(java.util.Collection<MessageType> types)
Match messages by message type. |
Method Summary | |
---|---|
boolean |
addSubject(OID oid)
Add a subject to the filter's subject OIDs. |
boolean |
addSubjectIfMissing(OID oid)
Add a subject to the filter's subject OIDs if not already present. |
boolean |
addTarget(OID oid)
Add a target to the filter's target OIDs. |
void |
addType(MessageType type)
Add to the matching message types. |
static void |
addUpdateTrigger(PerceptionUpdateTrigger updateTrigger)
|
boolean |
applyFilterUpdate(FilterUpdate update,
AgentHandle sender,
SubscriptionHandle sub)
(Internal use only) Called by the MessageAgent to apply
a FilterUpdate . |
boolean |
getMatchAllSubjects()
True if the local filter matches all subjects. |
boolean |
getMatchSubjects()
True if the remote filter matches subjects added by the subscriber. |
java.util.Collection<MessageType> |
getMessageTypes()
Get the matching message types. |
java.util.List<ObjectType> |
getSubjectObjectTypes()
Get subject object type filter. |
boolean |
hasSubject(OID oid)
True if subject is in the filter. |
boolean |
hasTarget(OID oid)
True if subject is in the filter. |
void |
marshalObject(AOByteBuffer buf)
Custom marshaller |
boolean |
matchMessageType(java.util.Collection<MessageType> types)
True if the given types intersects the filter's
message types. |
boolean |
matchRemaining(Message message)
True if the message matches filter criteria. |
boolean |
removeSubject(OID oid)
Remove a subject from the filter's subject OIDs. |
boolean |
removeTarget(OID oid)
Remove a target from the filter's target OIDs. |
void |
setMatchAllSubjects(boolean match)
Match all subject OIDs in the local filter. |
void |
setMatchSubjects(boolean match)
Match subjects added by the subscriber. |
void |
setSubjectObjectTypes(java.util.Collection<ObjectType> subjectTypes)
Set subject object types for which you want SubjectMessages. |
void |
setTypes(java.util.Collection<MessageType> types)
Set the message types to match. |
java.lang.String |
toString()
|
protected java.lang.String |
toStringInternal()
|
java.lang.Object |
unmarshalObject(AOByteBuffer buf)
Custom marshaller |
Methods inherited from class atavism.msgsys.Filter |
---|
applyFilterUpdate, getReceiveFilterTable, getResponderReceiveFilterTable, getResponderSendFilterTable, getSendFilterTable |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface atavism.msgsys.IFilter |
---|
getReceiveFilterTable, getResponderReceiveFilterTable, getResponderSendFilterTable, getSendFilterTable |
Field Detail |
---|
public static final int FIELD_TARGETS
FilterUpdate
public static final int FIELD_SUBJECTS
FilterUpdate
Constructor Detail |
---|
public PerceptionFilter()
public PerceptionFilter(java.util.Collection<MessageType> types)
Method Detail |
---|
public void setTypes(java.util.Collection<MessageType> types)
setTypes
in interface IMessageTypeFilter
public void addType(MessageType type)
addType
in interface IMessageTypeFilter
public java.util.Collection<MessageType> getMessageTypes()
getMessageTypes
in interface IFilter
getMessageTypes
in interface IMessageTypeFilter
getMessageTypes
in class Filter
public boolean getMatchAllSubjects()
public void setMatchAllSubjects(boolean match)
public boolean getMatchSubjects()
public void setMatchSubjects(boolean match)
public boolean addSubject(OID oid)
public boolean addSubjectIfMissing(OID oid)
public boolean hasSubject(OID oid)
public boolean removeSubject(OID oid)
public boolean addTarget(OID oid)
FilterUpdate
if addTarget() returns true.
oid
is a new target.public boolean hasTarget(OID oid)
public void setSubjectObjectTypes(java.util.Collection<ObjectType> subjectTypes)
subjectTypes
. This option only
works when PerceptionFilter is combined with PerceptionTrigger
.
public java.util.List<ObjectType> getSubjectObjectTypes()
setSubjectObjectTypes(java.util.Collection)
public boolean removeTarget(OID oid)
FilterUpdate
if removeTarget() returns true.
oid
reference count drops to zero.public boolean matchMessageType(java.util.Collection<MessageType> types)
types
intersects the filter's
message types.
matchMessageType
in interface IFilter
matchMessageType
in class Filter
public boolean matchRemaining(Message message)
Matches TargetMessage target OID in the filter's target set.
Matches SubjectMessage subject OID in the filter's target or subject set.
Matches PerceptionMessage target OIDs in the filter's target set.
matchRemaining
in interface IFilter
matchRemaining
in class Filter
public boolean applyFilterUpdate(FilterUpdate update, AgentHandle sender, SubscriptionHandle sub)
MessageAgent
to apply
a FilterUpdate
.
applyFilterUpdate
in interface IFilter
applyFilterUpdate
in class Filter
MessageAgent.applyFilterUpdate(long, atavism.msgsys.FilterUpdate)
public static void addUpdateTrigger(PerceptionUpdateTrigger updateTrigger)
public void marshalObject(AOByteBuffer buf)
marshalObject
in interface Marshallable
buf
- The byte bufferpublic java.lang.Object unmarshalObject(AOByteBuffer buf)
unmarshalObject
in interface Marshallable
public java.lang.String toString()
toString
in class java.lang.Object
protected java.lang.String toStringInternal()
toStringInternal
in class Filter
|
Copyright © 2018 Dragonsan Studios Sp. z o.o. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |