Search code examples
javaprotostuff

RuntimeSchema in Protostuff 1.3.8


I am trying to learn how to use Protostuff. I have an example that uses protostuff 1.0.7. In this example the class RuntimeSchema is used.

When I try to reproduce the code with a current version of protostuff (1.3.8), I fail, because the class RuntimeSchema does not seem to exist. I searched the net for a current tutorial but all I could find was: https://github.com/protostuff/protostuff/wiki/Examples which, honestly, I don't understand.

Can someone help me understand how protostuff is supposed to be used in the current version?


Solution

  • I checked up on my own code to have a look for you, and here is what I am doing:

    LinkedBuffer buffer = LinkedBuffer.allocate(2048);
    Schema<Order> orderSchema = RuntimeSchema.getSchema(Order.class);
    
    ProtostuffIOUtil.toByteArray(order2, orderSchema, buffer);
    buffer.clear();
    

    So the same really as the examples. The only thing I can suggest doing is that your POM includes all three dependencies:

    • Protostuff Runtime (the one you are probably missing)
    • Protostuff API
    • Protostuff Core

    In the future the best thing to look at for a problem like this is always that you have all necessary dependencies.