Jump to: navigation, search

Difference between revisions of "COSMOS Programming Model"

(Getting Code from CVS)
(Class Diagram)
Line 10: Line 10:
=== Class Diagram ===
=== Class Diagram ===
The following diagram depicts the class hierarchy of the COSMOS data manager framework. 

Revision as of 23:10, 13 January 2008

COSMOS provides a framework for collecting and visualizing data for system administration applications. By leveraging the COSMOS framework and providing the necessary extensions, programmers can quickly and easily create applications for collecting data from disparate data sources, and making data available through standard-based APIs or an easy-to-use user interface. This document explains the programming model used in extending the COSMOS framework.

Creating a Data Manager

Preparing Development Environment

  • Download eclipse platform SDK and install it by unzipping it to a directory.
  • Download COSMOS SDK from COSMOS download page.
  • Install the SDK by unzipping it on top of your eclipse installation directory.
  • (Optional) While developers don't need to change the framework code, it may sometimes be useful to have the source of the COSMOS framework in the workspace. You can import the source code from CVS with a project set file (PSF) provided on the download page.

Class Diagram

The following diagram depicts the class hierarchy of the COSMOS data manager framework. DataManagerClassDiagram.jpg

Data Manager Architecture Block Diagram


Creating an MDR

Prerequisite: Import the framework bundles into workspace or install them in the target platform. Note: org.eclipse.cosmos.example.mdr and org.eclipse.cosmos.rm.sml.mdr in CVS can be used as examples for creating an MDR. The following steps show how to create an MDR.

  • Create a plug-in project. In the "Target Platform" section, select "an OSGi framework", and select "standard" from the dropdown box. Click next to provide plugin ID, name, etc, and click Finish.
  • Edit the MANIFEST.MF file in the Plug-in Manifest Editor. On the Dependencies tab, add the following dependencies and save the file:
    • org.apache.muse.complete
    • org.eclipse.cosmos.dc.mdr
  • Create a class in this bundle that provides the implementation of the MDR.
    • Annotate the class as a ManagedResource
    • Extend AbstractMDR class
    • Implement IDataManager and IMdrQuery (Although the superclass already implements these interfaces, we need this step as a temporary workaround for a bug in the management bundle.) The class signature looks something like this:
public class MyMDR extends AbstractMdr implements IDataManager, IMdrQuery
  • Implement the getSelectorHandlerFactory method, which is an abstract method from the super class. This method should eturn an instance of org.eclipse.cosmos.dc.cmdbf.services.provisional.query.service.ISelectorHandlerFactory. A selector handler factory is a factory class that creates handlers for CMDBf query. Read more about the CMDBf query processing framework from this wiki page.
  • An activator class is generated when the OSGi bundle is created. Open the Activator java file in the editor. COSMOS framework comes with an abstract activator that contains code required by the activators of all data managers. Make the following updates in the activator java class:
    • Remove the "start" and "stop" method stubs generated by the eclipse.
    • Make the Activator class extend AbstractDataManagerActivator
    • Implement the getDataManagerInstance abstract method. The method will return an instance of the class that implements the capabilities. The activator will look like the following.
public class Activator extends AbstractDataManagerActivator {

	protected IDataManager getDataManagerInstance() {
		return new MyDataManager();

  • Provide data manager configuration file: add a file call config.properties in the META-INF directory. This file contains configurable parameters for the data manager. The keys in the properties files are defined as constants in the IDataManager interface. The config values can be retrieve from the data manager implementation class using the getConfigProperty method inherited from AbstractDataManager. Here is a template of the config file:
# URI of the management domain

# Resource ID of the management domain

# URI of the data manager EPR

# Resource ID of the data manager

# Display name of the data manager

# Classification of the data manager

# Dialect of the data manager
DIALECT=my dialect

Providing Custom Capabilities

A data manager can expose operations that are not part of the CMDBf specification by providing a custom capability and implementation.

The convention is to put code for the data manager in three bundles:

  1. API bundle: (e.g. org.eclipse.cosmos.dc.sandbox.example.common) This "common" bundle is used by both the server and the client.
  2. Implementation bundle: Server code that provides implementation of the custom capability.
  3. Client proxy: remote API for the data manager.

A capability is declared as a Java interface. (See org.eclipse.cosmos.dc.datamanager.example.api.ICustomCapability as an example. Please note the following components in the capability interface:

  • The interface declaration is decorated by the following annotation. Namespace is declared as a public constant in the interface class.
  • Methods are decorated by the @ManagedOperation annotation.
  • The URI and QName of each operation and their parameters are also declared in the interface.

The steps for creating the implementation bundle is same as those used to create a basic MDR as described in the previous section. The difference is that the data manager implementation class will also implement the custom capability API in the class declaration, and provide the implementation in the class.

Client proxy for the MDR and Data Manager

The org.eclipse.cosmos.dc.sandbox.datamanager.client and org.eclipse.cosmos.dc.sandbox.mdr.client bundles provide the client proxies for the data manager and MDR. If the client application is simply invoking the COSMOS data manager capabilities and the CMDBf query API remotely, this two client implementation is sufficient. (For an example, see how the client application uses the proxies in the test code in org.eclipse.cosmos.dc.sandbox.datamanager.test.)

Subclass from MDRClient or DataManagerClient when you need to provide a client proxy of a data manager that provides custom capabilities.

Running the MDR within Eclipse

  • Select Run > Open Run Dialog...
  • Create a new OSGi Framework profile.
  • Select all plug-ins in the workspace and deselect all plugins in the Target platform. Then click on "Add Required Bundles" button.
  • Select a few extra bundles from the target platform:

javax.mail.api, javax.saaj.api, muse.osgi.soa.mini, org.apache.commons.httpclient, org.apache.commons.logging(1.0.4), org.eclipse.equinox.ds, org.eclipse.equinox.http.jetty, org.eclipse.equinox.log

  • Then click the "Add Required Bundles" button again.
  • Click "Run" button.