Chassis App Samples
The Chassis App samples show how to add custom objects to the Inventory, display the standard object views, handle relations between objects, plus other UI features. It comes in 2 versions that must run independently: start with the chassis-ui and chassis-service for the simplest implementation, introducing chassis objects, chassis views and actions. Then look at chassisRackVSphere-ui and chassisRackVSphere-service for a more complete implementation with object relations and advanced data provider.
The different versions of chassis app cannot run together because they share the same object types, extension points, etc. You must undeploy one version before deploying the next one.
The data used here is very simplistic and hard-coded in the java adapters, a real implementation would make a connection to a back-end server or database. Note that your java plugins must remain light-weight processes.
chassis-ui and chassis-service
Description
Chassis-ui shows how extension templates makes it easy to create a standard vSphere object workspace for custom objects, with minimal amount of code. On the Java side a ChassisDataAdapter is implemented to handle all UI requests concerning the "samples:Chassis" type or its properties.
Usage
To run the sample in Eclipse/STS, import both projects chassis-ui and chassis-service, build them and deploy the bundles to the server; chassis-service must be added first since chassis-ui depends on the existence of the service to be deployed successfully. Start a client session and select the vCenter inventory. You should see a new category Chassis App with a node containing Chassis objects.

Drill down the Chassis node to display the Chassis objects list. The list toolbar has 3 icons to create, edit or remove a chassis. The drop-down Action menu contains the context-specific actions (edit or remove). "Create Chassis" lets you add new objects. "Edit Chassis" toggles the value of the Server Type property of a chassis.
Notes:
The chassis names are not sorted, even if you click on the Name header, because this simpler version don't implement sorting in the chassis-service project.
The Filter box cannot be used because the corresponding search code is not there in ChassisDataAdapter, see the other version below for these advanced features.

Select any Chassis object to display its information in the standard object workspace, using the top level tabs Summary, Manage and Monitor. The Summary view contains some basic header information and two "portlets" underneath. Note that you don't have to use this portlet format and could provide custom content to the whole summary view.

The Monitor and Manage tabs contain an empty view to demonstrate the role of those extensions. If you don't add any Monitor or Manage views in your plugin the corresponding tab won't be displayed. (Note that the Related Objects tab is absent because extension com.vmware.samples.chassis.related was excluded in plugin.xml.)
Clicking on the Actions drop-down shows the actions available for the selected item: Edit Chassis and Remove Chassis are the only actions in the top menu and in the toolbar because they have been prioritized as the most important ones to access. Non prioritized actions like Other Action show up in a sub-menu.
Click on the pen icon to trigger the Edit Chassis action. The only visible effect is a change in the Server Type value.
When no item is selected in the list the Actions drop-down disappears and the toolbar contains only "global actions" such as Add Chassis represented by the + sign.
The Add Chassis action opens a wizard that let's you enter the new chassis' properties. You can also minimize the dialog in the top right corner to leave it in the Work In Progress section on the right, and resume the wizard at a later time. See the chassis-ui code for more details on the implementation and other features.
Wizards are provided only as "internal APIs" in SDK 5.5, i.e. it is not guaranteed to be compatible with the next major release. You can take advantage of those APIs in 5.5 but you will likely have to update your plugin when the next version comes out.
Implementation notes
plugin.xml contains all the extension information for chassis-ui:
- We extend vise.navigator.nodespecs to create a "Chassis App" category in the Inventory view.
- Then we use the extension template vsphere.core.inventorylist.objectCollectionTemplate to add the Chassis "object collection node" under that category.
- The extension template vsphere.core.inventory.objectViewTemplate defines the object workspace for the Chassis object, i.e. it is the one that creates the standard tab hierarchy (Getting Started, Summary, Monitor, Manage, Related Objects, and their sub-tabs) which allows to leverage existing views and keep the UI consistent. Note that we exclude the extension com.vmware.samples.chassis.related to remove the Related Objects tab which would be empty otherwise.
- The extension template vsphere.core.inventory.summaryViewTemplate creates a Summary page similar to other vSphere objects: the summaryHeaderView is displayed at the top. The bottom area contain 2 portlets created with the extension point com.vmware.samples.chassis.summarySectionViews. Note that you could also define a custom summary view by extending directly the extension point {namespace}.summaryViews (i.e. where your UI takes over the whole Summary tab).
- The column data displayed in the "Objects" tab's list is implemented with the extension point com.vmware.samples.chassis.list.columns, itself created by the template.
- Two actions are added that will appear in a context menu on chassis objects.
- Notice that the object type is samples:Chassis, the namespace is important to avoid collisions with other plugins.
ChassisActionCommand.as implements the handlers for menu actions (see also the Actions sample for more info). Notice the use of ModelChangeEvent when an object is created or modified. This event must be dispatched with the proper OperationType to notify the framework that an object in the collection was changed, otherwise the list will not refresh properly.
ChassisServiceImpl.java is the java side implementation of the menu actions.
ChassisDataAdapter.java:
- This class implements the DataProviderAdapter interface for providing new objects and property values.
- The annotation @type("samples:Chassis") at the top is all that is required to register the DataProviderAdapter with the right object type.
- getData() is the main entry point. In order to understand how the framework calls this adapter at multiple times depending of the current view, and how the logic gets executed for different queries, we recommend to use your Java debugger and step through the code after you start Virgo in debug mode.
The normal pattern is to validate the queries coming in and ignore the ones not handled by this adapter.
This version doesn't handle all the types of of queries, see CHassisRackVSphereDataAdapter below for a more advanced version.
ObjectStore implements a simple in-memory store for chassis data as this sample doesn't use any back-end service. A real implementation should not cache its object data the same way!
chassisRackVSphere-ui and chassisRackVSphere-service
Description
ChassisRackVSphere-ui extends the implementation of Chassis-ui to add custom Rack objects and relations between chassis and racks and between chassis and vSphere hosts. These relations are created in ChassisRackVSphereDataAdapter on the java side. Other improvements include customized icon and label in the inventory, paging, sorting and text search in the list view.
Usage
To run the sample in Eclipse/STS, import both projects, build them and deploy the bundles to the server; chassisRackVSphere-service must be added first since chassisRackVSphere-ui depends on the existence of the service to be deployed successfully. Start a client session and select the vCenter inventory. The Chassis App inventory node now displays two types of objects:

This version handles sorting and pagination in the chassis and rack lists. The names are now listed in alphabetical order. Click on the name header to reverse the order. If you change the default number of chassis in the code to a higher number you can scroll down the list and see more pages being requested to the server.

You can type some text in the Filter box to reduce the list to matching properties.

The chassis Summary, Monitor and Manage tabs are similar to the simpler chassis-ui version, but now a Related Objects tab shows the rack this chassis may belong to, and the hosts it may contain:

The list of racks uses a different icon and adds the label "(Empty)" for racks that don't contain any chassis:

The rack's Related Objects tab shows the list of chassis associated with this rack. It re-uses automatically the same list, toolbar and actions menu than in the Chassis list view.

Click on a chassis Related Objects tab to see the list of hosts located on this chassis (depending on how many hosts your setup has all the chassis may not have been assigned a host). This is the same hosts list visible in other parts of the Web Client, it gets imported automatically by the virtue of relationships! See vsphere.core.host.list in plugin.xml.

Click on one of the hosts in the list above to navigate to that host's workspace. The host's Related Objects tab includes a new Chassis list in addition to the other existing vSphere relations. (see vsphere.core.host.related in plugin.xml)

Implementation notes
In plugin.xml the main differences over chassis-ui are:
The extension com.vmware.samples.relateditems.specs.chassis where the RelationSpec are declared for chassis-rack and chassis-host relations.
The various extensions defining the rack UI, similar to the ones defining the chassis UI.
The extension of the view vsphere.core.host.related to display the chassis associated with a host.
The use of vise.inventory.representationspecs to display custom icon and label in Rack lists.
ModelObjectUriResolver.java demonstrates how to implement a ResourceTypeResolver for URI objects. URI is the recommended type for custom objects exchanged between the UI and Java layers. You can also extend the URI class if you need to carry more information to the UI.
ChassisRackVSphereDataAdapter.java is a more complete implementation than ChassisDataAdapter.java.
- A VimObjectReferenceService needs to be injected in the constructor to handle Host references (vSphere objects don't have a type known by the SDK so they can only be manipulated through a wrapper service).
- The host to chassis relation has to be handled using its inverse counterpart because this is not known to the existing "host plugin" in the vSphere Web Client platform.
- getRelatedItems() can now deal with these reverse relations.
- processPropertyConstraint() was added to handle search queries for the Filter box.
- processCompositeConstraint() was improved to handle the AND case.
See also: Other samples - SDK Tutorial - FAQs -
Flex API docs - Java API docs