COSMOS Developer's Guide


Adding or extending resource and operation handlers

This topic will describe the steps needed to add or extend resource and operation handlers within the SDD Runtime.


After checking out the base implementation of the SDD runtime, you may wish to customize aspects of it to fit your needs. We will discuss those options now. The SDD Runtime uses what we refer to as "handlers" to determine if requirements on resources within an SDD are met. These are called Resource Handlers and their classes implement the IResourceHandler interface. We also have what we call Operation Handlers, or Op Handlers. These handlers take care of the different operations that can be performed by the SDD Runtime. The only operation currently supported is install These classes implement the IOperationHandler interface. Now that you have an understanding of the terminology, we can discuss how you can add custom handlers to our runtime.

Resource Handlers

Resource Handlers are called based on the resource's type from within the SDD. They advertise themselves to OSGi through an XML file that tells OSGi which QName they are associated with. The RequirementsResolver then looks at the type of the resource and asks OSGi for the accompanying ResourceHandler implementing the IResourceHandler interface. It then passes the requirements for the resource in question to the handler so that it can resolve them. So to create a new Resource Handler, you need to create a new XML file within the OSGI-INF folder of the profile.cim project that specifies the new class, which type it is for and which interface it uses. You also need to edit the Service-Component section of the manifest to add in a reference to our new file. Note that you do not have to use the profile.cim project, other projects may be created for separate profiles. As long as they have the correct OSGI-INF and manifest information in order to let OSGi aware of themselves and Implement our IResourceHandler interface, they will be made available to other packages.

Operation Handlers

Operation Handlers work very much the same way. You can specify how you want a particular type of artifact to be handled through an operation handler. Again, you need an OSGI-INF file specifying the type that our new operation is for, and you need to add this file into the manifest. Then the OperationHandler implementation will query OSGi for a corresponding service, and if it finds one with call the methods inside of it that implement the OperationHandler interface.

Through following these constructs we allow new types and their corresponding resolvers and handlers to be freely added and called, without changes to the actual runtime.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]