IgniteMessageFactoryImpl implements IgniteMessageFactory { @Override public void register(short directType, Supplier<Message> supplier) throws IgniteException { if (initialized) { throw new IllegalStateException("Message factory is already initialized. " + "Registration of new message types is forbidden."); } int idx = directTypeToIndex(directType); Supplier<Message> curr = msgSuppliers[idx]; if (curr == null) { msgSuppliers[idx] = supplier; minIdx = Math.min(idx, minIdx); maxIdx = Math.max(idx, maxIdx); cnt++; } else throw new IgniteException("Message factory is already registered for direct type: " + directType); } IgniteMessageFactoryImpl(MessageFactory[] factories); @Override void register(short directType, Supplier<Message> supplier); @Override @Nullable Message create(short directType); short[] registeredDirectTypes();  }
@Test(expected = IllegalStateException.class) public void testReadOnly() { MessageFactory[] factories = {new TestMessageFactoryPovider(), new TestMessageFactory()}; IgniteMessageFactory msgFactory = new IgniteMessageFactoryImpl(factories); msgFactory.register((short)0, () -> null); }