VMware Communities > Blogs > Developer Center Blog > 2008 > May > 14

Blog Posts

Developer Center Blog

Previous Next
0

I presented the Java API for VI SDK at VMware Technology Exchange in San Jose yesterday and got very positive feedbacks.

Here are two UML diagrams I used in my presentation. I think they are very helpful to understand the API and the design thoughts behind it.

1. The overall object model

overall.JPG


It can be inferred from our VI SDK API reference. Please note that we don't have a managed object type called ManagedObject in our reference. This is a type defined to capture all the common properties and behaviors of all managed objects. Given the limited size, I only show the names of the types, not properties and methods.

To better group these managed object types, I used colors. On the right most side of the diagram are the ServiceInstance class and various "manager" classes like AuthorizationManager. From the ServiceInstance, you can get any object of these types with single call, for example getAuthorizationManager().

In the middle of left side, you can find ManagedEntity class and its sub-classes like HostSystem, VirtualMachine. These classes represent all the items you could find in the inventory tree from VI client. They are the most important managed objects in the whole model, and all tagged with orange color except the HostSystem.

The HostSystem is very much like ServiceInstance in that it has many "System" or "Manager" types closely attached to it, for example, HostDatastoreSystem. You can get hold of these objects with a single method call from a HostSystem object. For this reason, both HostSystem and all the attached classes are tagged the same color.

2. A detailed partial UML diagram

detail.JPG

This UML diagram is extracted from the overall model but adds much more details with properties and methods. If you can understand this diagram, you can then easily understand all the other managed object types.

The ManagedObject class holds three properties:

1. mor of type ManagedObjectReference -- pointing to the ManagedObjectReference object that is used to represent a managed object in VI SDK.

2. serverConnection of type ServerConnection -- pointing to the ServerConnection object I will cover later.

3. objectContent of type ObjectContent -- used for local caching for better performance.

Besides accessors, the class has getCurrentProperty() method defined to encapsulate the PropertyCollector. This method gets called in subclasses to get a property. For example, the getName() in ManagedEntity called it like (String) getCurrentProperty("name"); In most of cases, you don't need to use it at all, I already provide explicit getter methods in concrete subclasses. I may change its visibility to protected later. The other two methods, "getCachedProperty() and refreshPropertyCache()" are designed for caching.

The ServerConnection is used to represent a connection to the server under a specific login user. It holds information like url to the server, the userSession with username etc., and vimService which is the JUMBO interfaces with 300+ methods. For convenience, ServerConnection also has a reference to a ServiceInstance object.

Now let us take a look at the ServiceInstance type. It's a special managed object and the first managed object you will have in a typical application logic flow. You can create a new ServiceInstance object by providing url/username/password, or url/sessionID combination. The later is not used as much as the first constructor, but very helpful when you develop a VI client plugin in Java. I will talk more about it later blogs.

According to the API reference, the ServiceInstance has a ServiceContent object, which holds all the ManagedObjectReferences to various "manager" attached to it, and an AboutInfo object. You can get any of them in a single call. ServiceContent object is, therefore, no long needed, and I don't even provide a getter to it.

The right side of the diagram are the ExtensibleManagedObject and its subclass ManagedEnity. E.M.O doesn't have methods defined at all, but three properties. Therefore it only has three corresponding getters.

ManagedEntity is one of the most important class given that VirtualMachine, HostSystem etc. are all inherited from it. Besides accessors and several methods, I provides some methods to retrieve items in the inventory tree. For example, you can easily find all the Virtual in one single call. Property is used within these methods, but you don't see it.

The above two ML diagrams should have given you a big picture about the object model and how key types are related to each other. If you really need to know more details. Please click into my May 8 posting and read the source code there. For sure, it will give you much more details than I can cover in these two ML diagrams.



There are no comments on this post