Atavism Version 2018.1AGIS API

atavism.server.engine
Class HookManager

java.lang.Object
  extended by atavism.server.engine.HookManager

public class HookManager
extends java.lang.Object

Manages hooks for processing messages coming in from a subscription. Hooks are associated with message types, which is a property in a message.

The EnginePlugin's onMessage() callback processes an incoming message by calling into its local HookManager and finding all matching hooks for the incoming message's message type for all the hooks. For each matching hook, it calls the hook's processMessage() method.

See Also:
EnginePlugin.handleMessageImpl(atavism.msgsys.Message, int)

Constructor Summary
HookManager()
          Normally created by the EnginePlugin class.
 
Method Summary
 void addHook(MessageType msgType, Hook hook)
          Adds a hook to the HookManager.
 java.util.List<Hook> getHooks(MessageType msgType)
          Returns this list of all hooks matching the message type.
 void removeHook(MessageType msgType, Hook hook)
          Remove hook from the hook manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HookManager

public HookManager()
Normally created by the EnginePlugin class. In order to avoid copying the list when getHooks is called, we copy it when we're adding to it. We do lock around addHook, so that different callers to addHook are synchronized against each other, but we don't lock in getHooks.

Method Detail

addHook

public void addHook(MessageType msgType,
                    Hook hook)
Adds a hook to the HookManager. You can associate more than one hook with a given message type which will be returned in order by getHooks().

Parameters:
msgType - the message type to match
hook - the hook to be called for matching messages
See Also:
EnginePlugin.handleMessageImpl(atavism.msgsys.Message, int)

removeHook

public void removeHook(MessageType msgType,
                       Hook hook)
Remove hook from the hook manager.


getHooks

public java.util.List<Hook> getHooks(MessageType msgType)
Returns this list of all hooks matching the message type. They are returned in the order they were added. The returned list should be treated as read-only.

Parameters:
msgType - the message type to match
Returns:
A list of all hooks matching the passed in message type.


Copyright © 2018 Dragonsan Studios Sp. z o.o.