Package org.apache.ignite.internal.managers.communication

## Class IgniteMessageFactoryImpl

- java.lang.Object
- - org.apache.ignite.internal.managers.communication.IgniteMessageFactoryImpl

All Implemented Interfaces:
  `MessageFactory`

    public class IgniteMessageFactoryImpl
    extends Object
    implements MessageFactory

Message factory implementation which is responsible for instantiation of all communication messages.

### Constructor Summary

Constructors
`IgniteMessageFactoryImpl​(MessageFactoryProvider[] factories)` Contructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`@Nullable Message` `create​(short directType)` Creates new message instance of provided direct type.
`void` `register​(short directType, Supplier<Message> supplier)` Register message factory with given direct type.
`short[]` `registeredDirectTypes()` Returns direct types of all registered messages.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### IgniteMessageFactoryImpl

    public IgniteMessageFactoryImpl​(MessageFactoryProvider[] factories)

Contructor.

Parameters:
  `factories` - Concrete message factories or message factory providers. Cfn't be empty or `null`.

### Method Detail

#### register

    public void register​(short directType,
                         Supplier<Message> supplier)
                  throws IgniteException

Register message factory with given direct type. All messages must be registered during construction of class which implements this interface. Any invocation of this method after initialization is done must throw `IllegalStateException` exception.

Specified by:
  `register` in interface `MessageFactory`
Parameters:
  `directType` - Direct type.
  `supplier` - Message factory.
Throws:
  `IgniteException` - In case of attempt to register message with direct type which is already registered.

#### create

    @Nullable
    public @Nullable Message create​(short directType)

Creates new message instance of provided direct type.

Specified by:
  `create` in interface `MessageFactory`
Parameters:
  `directType` - Message direct type.
Returns:
  Message instance.
Throws:
  `IgniteException` - If there are no any message factory for given `directType`.

#### registeredDirectTypes

    public short[] registeredDirectTypes()

Returns direct types of all registered messages.

Returns:
  Direct types of all registered messages.