users@jersey.java.net

best practice for generating unique id in the resources

From: Arul Dhesiaseelan <arul_at_fluxcorp.com>
Date: Fri, 31 Oct 2008 14:25:54 -0600

Hello,

I have a CustomersResource with sub-resource CustomerResource :

/customers/{id} =>

/customers/1909
/customers/2234
/customers/3454

The client can add customers to the customers resource using POST. But,
it needs to populate the unique id which forms part of the URI as well
as customer ID.

What would be the best method to generate such unique id?

I can think of an ID generator service on the server-side and the client
can first do a GET to get an ID and use this ID in the POST to create a
new customer.

Would this approach cause any issue? Is there a better approach to
implement this behavior?

Appreciate your suggestions.

Thanks!
Arul