public static void main(final String[] args) throws Exception
    {
        System.out.println("\n*** Extension Stub Example ***");

        final ByteBuffer byteBuffer = ByteBuffer.allocate(4096);
        final UnsafeBuffer directBuffer = new UnsafeBuffer(byteBuffer);

        final extension.MessageHeaderDecoder messageHeaderDecoder = new extension.MessageHeaderDecoder();
        final baseline.MessageHeaderEncoder messageHeaderEncoder = new baseline.MessageHeaderEncoder();
        final baseline.CarEncoder carEncoder = new baseline.CarEncoder();
        final extension.CarDecoder carDecoder = new extension.CarDecoder();

        final int encodingLengthPlusHeader = encode(carEncoder, directBuffer, messageHeaderEncoder);

        // Optionally write the encoded buffer to a file for decoding by the On-The-Fly decoder

        final String encodingFilename = System.getProperty(ENCODING_FILENAME);
        if (encodingFilename != null)
        {
            try (FileChannel channel = FileChannel.open(Paths.get(encodingFilename), READ, WRITE, CREATE))
            {
                byteBuffer.limit(encodingLengthPlusHeader);
                channel.write(byteBuffer);
            }
        }

        // Decode the encoded message

        final int bufferOffset = 0;
        messageHeaderDecoder.wrap(directBuffer, bufferOffset);

        // Lookup the applicable flyweight to decode this type of message based on templateId and version.
        final int templateId = messageHeaderDecoder.templateId();
        if (templateId != extension.CarEncoder.TEMPLATE_ID)
        {
            throw new IllegalStateException("Template ids do not match");
        }

        decode(carDecoder, directBuffer, messageHeaderDecoder);
    }
Main entry point for the example.

@param args which are ignored.
@throws Exception if an error occurs when parsing the XML or doing IO.
sbe-samples/src/main/java/uk/co/real_logic/sbe/examples/ExampleUsingGeneratedStubExtension.java