Difference between revisions of "COSMOS Programming Model"

From Eclipsepedia

Jump to: navigation, search
(Providing Custom Capabilities)
Line 37: Line 37:
  
 
=== Providing Custom Capabilities ===
 
=== Providing Custom Capabilities ===
A data manager can expose operations that are not part of
+
A data manager can expose operations that are not part of the CMDBf specification by providing a custom capability and implementation.  The org.eclipse.cosmos.dc.sandbox.example.* bundles provide an example on how to create a data manager with custom APIs. 
 +
 
 +
The convention is to put code for the data manager in three bundles:
 +
# API bundle: (e.g. org.eclipse.cosmos.dc.sandbox.example.common)  This "common" bundle is used by both the server and the client. 
 +
# Implementation bundle: Server code that provides implementation of the custom capability. 
 +
# 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.
 +
@ManagedResourceCapability(namespace=____)
 +
* 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 implemtation bundle is same as those used to create a basic MDR as described in the prvious section.  The difference is that the data manager implementation class will also implement the custom capability API in the class delaration, and provide the implementation in the class.
  
 
=== Client proxy for MDR and Data Manager ===
 
=== Client proxy for MDR and Data Manager ===

Revision as of 16:34, 10 October 2007

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.

Contents

Creating a Data Manager

Getting Code from CVS

Class Diagrams

Creating an MDR

Prerequisite: Import the framework bundles into workspace or install them in the target plaform. Note: org.eclipse.cosmos.rm.sandbox.dataManager.sml bundle is an implementation of an MDR that uses an SML repository as the backend datastore. Please refer to it as an example for creating an MDR. The following steps show how to create an MDR.

  • Create a plugin 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.sandbox.dataManager
    • org.eclipse.cosmos.dc.sandbox.mdr
  • Create a class in this bundle that provides the implementation of the
    • 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:
@ManagedResource
public class MyMDR extends AbstractMdr implements IDataManager, IMdrQuery
  • Implemnet methods declared in interfaces and abstract methods from super class. For example, the query method takes a CMDBf query as input. Provide adapter code here to parse the query, talk to the data source, and return the response in CMDBf response format. The logic for parsing the query, invocation of APIs of data source and transforming the query output to CMDBf query response can take place in another class or OSGi bundle.
  • An activator class is generated when the OSGi bundle 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 abract 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();
	}

}

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 org.eclipse.cosmos.dc.sandbox.example.* bundles provide an example on how to create a data manager with custom APIs.

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.
@ManagedResourceCapability(namespace=____)
  • 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 implemtation bundle is same as those used to create a basic MDR as described in the prvious section. The difference is that the data manager implementation class will also implement the custom capability API in the class delaration, and provide the implementation in the class.

Client proxy for MDR and Data Manager

Writing a Custom Data Manager Proxy

Packaging for deployment