I am trying to study how the REST service approach works using Jersey.
I have come up with 2 options when creating and accessing a REST service.
I have 6 parameters which are all string
- Pass the data as a long comma separated string and at server side split it.
- Use JAXB and do Marshalling and Unmarshalling.
I can understand that 1st option will be the fastest but does anyone knows how much fast it will be than the 2nd option and is it a safe and efficient way to do this.
- It will be nice if someone can mention any more options that are possible..
Thanks
You’ll have to write your own MessageBodyReader/Writter if you want the comma separated string. Also you’ll need to make sure the parameter itself does not contain a comma, etc. Not that it would be a blocker – just noting that.
You can also use low-level JSON marshaling/unmarshaling using Jettison – that should also be pretty fast. Or use jackson. See various JSON mapping options in Jersey user-guide.
Just for completeness, another option might be to use Form (which is essentially a map of String->List) – if you use that, no need for a special MessageBodyReader/Writter – Jersey will handle it for you. You just need to annotate your methods with @Produce/@Consume(“application/www-form-urlencoded”).