Class ProtocolRepository

java.lang.Object
com.yahoo.messagebus.ProtocolRepository

public class ProtocolRepository extends Object
Implements a thread-safe repository for protocols and their routing policies. This manages an internal cache of routing policies so that similarly referenced policy directives share the same instance of a policy.
Author:
Simon Thoresen Hult
  • Constructor Details

    • ProtocolRepository

      public ProtocolRepository()
  • Method Details

    • putProtocol

      public void putProtocol(Protocol protocol)
      Registers a protocol with this repository. This will overwrite any protocol that was registered earlier that has the same name. If this method detects a protocol replacement, it will clear its internal routing policy cache.
      Parameters:
      protocol - The protocol to register.
    • hasProtocol

      public boolean hasProtocol(String name)
      Returns whether or not this repository contains a protocol with the given name. Given the concurrent nature of things, one should not invoke this method followed by getProtocol(String) and expect the return value to be non-null. Instead just get the protocol and compare it to null.
      Parameters:
      name - The name to check for.
      Returns:
      True if the named protocol is registered.
    • getProtocol

      public Protocol getProtocol(String name)
      Returns the protocol whose name matches the given argument. This method will return null if no such protocol has been registered.
      Parameters:
      name - The name of the protocol to return.
      Returns:
      The protocol registered, or null.
    • getRoutingPolicy

      public RoutingPolicy getRoutingPolicy(String protocolName, String policyName, String policyParam)
      Creates and returns a routing policy that matches the given arguments. If a routing policy has been created previously using the exact same parameters, this method will returned that cached instance instead of creating another. Not that when you replace a protocol using putProtocol(Protocol) the policy cache is cleared.
      Parameters:
      protocolName - The name of the protocol whose routing policy to create.
      policyName - The name of the routing policy to create.
      policyParam - The parameter to pass to the routing policy constructor.
      Returns:
      The created routing policy.
    • getRoutingPolicy

      public final RoutingPolicy getRoutingPolicy(com.yahoo.text.Utf8String protocolName, String policyName, String policyParam)
    • clearPolicyCache

      public void clearPolicyCache()
      Clears the internal cache of routing policies.