tags:

views:

54

answers:

1

In my current application i want to create and configure osgi services at runtime through a user interface. I've looked into the OSGi Metatype specification but it only supports simple type attributes.

So my questions are: Is there a good reason why there is no support for attribute types such as other osgi services and does anyone know about an already existing project that does something like this?

UPDATE

To further clarify my question:

What i want to do is to create and configure new services as needed by the user of the software. This should even work if new service interfaces are added to the system.

Lets assume i have a service interface for sending notifications

public interface NotificationService {
    void notify(Notification n);
}

and an implementation for sending notifications to e.g. Twitter. Through the Metatype specification i could encode the information that the twitter service needs a username and password. This allows me to dynamically create a UI at runtime for creating new twitter notification services.

This works with simple datatypes, but the Metatype spec does not handle dependencies to other services. E.g. lets say a Notification has file attachment and therefore the Twitter service needs a FileUpload service to store files.

A: 

You can always inject new services using BundleContext#registerService(), however the service at that time must have been initialized and ready to run. You may find useful the new Blueprint service of the OSGi 4.2 specification - or even Dynamic Services, which is older but more widespread.

In the end, it depends on what you want to do. When you say "create" and "configure" osgi services at runtime, what do you mean?

Tassos Bassoukos
I tried to clarify my question through an example. I hope this helps to understand what i want to do.
crazymaik
Got the example. The Metatype service cannot help you, and I think it's not a good match to the use case you envision. What you can do is have a simple string-valued property with options for the specific file upload service(s) that are available (of course this hardcodes dependencies between services - what happens if you add a bundle with a new file upload service?) and then using a ServiceTracker get the service with a custom property filter.I think using your own metadata description system (use annotations!) will work better for you. Or even the Eclipse Registry.
Tassos Bassoukos
Just wondering if this answers crazymaik's original question.
Marcel Offermans