incubator-cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rohit Yadav <bhais...@apache.org>
Subject Re: what is @EntityReference?
Date Tue, 22 Jan 2013 23:43:34 GMT
On Tue, Jan 22, 2013 at 3:12 PM, Frank Zhang <Frank.Zhang@citrix.com> wrote:
> I see this annotation refers to some interfaces on API response object.
> What is it?

What: follow the details.

> Do I have to use it when creating a new API response object?
Yes.

Details:

All apis are grouped around a common entity for ex. for vm the apis
that are related are list/create/delete/start/stop etc. All of these
cmd classes have a response object which is a response class, so a
non-idempotent api (which effect in changing state or existence like
delete) the response class would be success response, otherwise it
would an entity response class. For example all template related apis
would have the same template response class.

So, we tag or annotate the response class with @EntityReference whose
value is an interface which is a contract that is implemented by a VO
class which has reference about the table name via its @Table
annotation. When DAOs are instantiated, a static map is populated with
*this* interface as key maps to the dao itself.

The way params are processed is such that all cmd params which have
entityType as CommandType.UUID are assumed to have an annotation which
would get us to a response class and in that response class we can use
the entity interface to get the dao to get the VO object by uuid and
finally get the id. This is how we translate over the wire uuids to
internal ids. While this is not the best way but a good way for now, a
better way would be to just retain these vo object and do acl etc. on
them (because using the id we again query to get the VO object down
the layers).

Hope this helps.

Mime
View raw message