I'll keep you posted on our progress. I think there are interesting things to learn from this approach.
Best wishes, Rodrigo On 7/24/07, Alex Karasulu <[EMAIL PROTECTED]> wrote:
Would be nice if this stuff could do ASN.1 to pack(). Perhaps that is something they may look into. Alex On 7/24/07, Mehmet D. AKIN <[EMAIL PROTECTED]> wrote: > > On 7/24/07, Trustin Lee <[EMAIL PROTECTED]> wrote: > > Hi Rodrigo, > > > > On 7/24/07, Rodrigo Madera <[EMAIL PROTECTED]> wrote: > > > Please tell me this wheel is invented and ready in MINA!! > > > > > > Here is the scenario taking as an example the SumUp server (the > closest > > > thing to the case). > > > Let's suppose there is this project called MegaMath, which is kind of > like > > > SumUp but has more operations: > > > > > > public class MegaMathMessage { > > > private byte opcode; > > > > > > MegaMathMessage(opcode) { > > > this.opcode = opcode; > > > } > > > > > > ... > > > } > > > > > > public class MultiplyMessage extends MegaMathMessage { > > > private byte operand0; > > > > > > MultiplyMessage() > > > { > > > super(Constants.MULTIPLY_OPCODE); > > > ... > > > } > > > > > > ... > > > } > > > > > > public class DoSomethingReallyNiceWithThreeArguments { > > > private int arg0; > > > private short arg1; > > > private byte arg3; > > > > > > // ... initialize with ctor etc... > > > } > > > > > > Now that we have the variable parameter quantity messages, we could > write > > > the decoders and encoders, but that's not nice. > > > > > > So the part we are writing let's us do basically this: > > > > > > NiceEngine.register(MultiplyMessage.class); > > > NiceEngine.register(SingASongMessage.class); > > > NiceEngine.register(DanceMessage.class); > > > > > > MessageEncoder multiplyMessageDecoder = > > > NiceEngine.getDecoder("MultiplyMessage"); > > > // classname or class can be used here. > > > MessageDecoder multiplyMessageEncoder = Nice... you get the > point... > > > > > > Is this available? > > > > It's not available. I think it's difficult to generalize. > > > > > The problem is that manually creating Decoders and Encoders is just a > waste > > > of time. This should be a machine's work, and this is what our design > is > > > promissing to aid us in. > > > > > > We tried using Javastruct, and even devoted three full days to writing > code > > > for it, but we came to the conclusion that we needed more and in a > more > > > structured manner, so we started this solution. > > > > > > If this is already implemented, please share some light on how to use > it. > > > > You could forward your feedback about JavaStruct to Mehmet so he can > > evolve it on and on. :) > > > > Thanks, > > Trustin > > -- > > what we call human nature is actually human habit > > -- > > http://gleamynode.net/ > > -- > > PGP Key ID: 0x0255ECA6 > > > > > Hi, > > I agree with Rodrigo on writing protocol encoders and decoders is > quite tedious job. That was the reason I was thinking something like > JavaStruct might help on these situations. He also helped me to find > some bugs and had some nice insight on the architecture. Thanks a lot. > > Although Rodrigo and his team found JavaStruct is not enough to handle > their problems, I still have a feeling that JavaStruct can be helpful > on many situations. Please look at the example codes below. There are > two examples, an Adobe Photoshop color book binary file reader - > writer and a Mina example. Mina example is based on the nice protocol > encoder-decoder tutorial on the wiki and it is not complete yet, but > if you look at the code you will get the idea. > > Examples: http://javastruct.googlecode.com/svn/trunk/javastruct/samples/ > > I also updated how-to documnent in the wiki. there is also usable 0.1 > jar in the downloads section. > > IMHO, Rodrigo's approach, (If I have gueesed correctly), automatic > generation of encoders and decoders have good and weak sides. It > probably generates code with better I/O performance (since for every > type of message, there will be an encoder-decoder generated > automatically, reading and writing directly to mina byte buffers. But > generating code has always drawbacks, difficult to maintain and > implement and sometimes considered as an anti pattern. I hope they > achieve good results and share their results with us. > > regards > Mehmet >