Package com.yahoo.messagebus.test
Class SimpleProtocol
- java.lang.Object
-
- com.yahoo.messagebus.test.SimpleProtocol
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SimpleProtocol.PolicyFactory
Defines a policy factory interface that tests can use to register arbitrary policies with this protocol.
-
Constructor Summary
Constructors Constructor Description SimpleProtocol()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPolicyFactory(java.lang.String name, SimpleProtocol.PolicyFactory factory)
Registers a policy factory with this protocol under a given name.RoutingPolicy
createPolicy(java.lang.String name, java.lang.String param)
Create a policy of the named type with the named param passed to the constructor of that policy.Routable
decode(com.yahoo.component.Version version, byte[] data)
Decodes the protocol specific data into a routable of the correct type.byte[]
encode(com.yahoo.component.Version version, Routable routable)
Encodes the protocol specific data of a routable into a byte array.java.lang.String
getName()
Returns a global unique name for this protocol.
-
-
-
Field Detail
-
NAME
public static final com.yahoo.text.Utf8String NAME
-
MESSAGE
public static final int MESSAGE
- See Also:
- Constant Field Values
-
REPLY
public static final int REPLY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:Protocol
Returns a global unique name for this protocol.
-
createPolicy
public RoutingPolicy createPolicy(java.lang.String name, java.lang.String param)
Description copied from interface:Protocol
Create a policy of the named type with the named param passed to the constructor of that policy.- Specified by:
createPolicy
in interfaceProtocol
- Parameters:
name
- the name of the policy to createparam
- the parameter to that policy's constructor- Returns:
- the created policy
-
decode
public Routable decode(com.yahoo.component.Version version, byte[] data)
Description copied from interface:Protocol
Decodes the protocol specific data into a routable of the correct type.
-
encode
public byte[] encode(com.yahoo.component.Version version, Routable routable)
Description copied from interface:Protocol
Encodes the protocol specific data of a routable into a byte array.
-
addPolicyFactory
public void addPolicyFactory(java.lang.String name, SimpleProtocol.PolicyFactory factory)
Registers a policy factory with this protocol under a given name. Whenever a policy is requested that matches this name, the factory is invoked.- Parameters:
name
- The name of the policy.factory
- The policy factory.
-
-