[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.technology.equinox] Re: DS - Difference between component factory and service factory

Hi Andrea,

did you find an answer to your question? I'm currently stuck on a somewhat similar use case, trying to define a LoggerFactory that returns a new Logger instance for every bundle requesting one.

However, I can't find a simple example on how to use a ComponentFactory with DS to get a reference to a component (and the service provided by it) created by the ComponentFactory. Do you know of an example / tutorial?

I think there should be something like this (Warning: this is not OSGi specs, only what I wish it would be):

<reference name="log" interface="my.Log" cardinality="1..1" policy="static" bind="bindLog" unbind="unbindLog">
<property key="loggername" value="TheLogger" />
</reference>


which uses the factory declared for the Logger service and passes the configuration with the attached <property> values to it. So, this is how I wish it to be working. But how is it working in the reality? What classes/interfaces need to be implemented?

I find the OSGi spec is very irritating in describing the whole component / service factory and DS stuff, as it's audience is OSGi bundle implementors as well as OSGi framework developers and there is no clear seperation in it.

I hope somebody of you can help me on this!

Kind regards, Daniel


Am 07.04.09 16:46, schrieb Andrea Zoppello:
Hi All,

I'm an OSGi beginner and i'm trying to understand how osgi-ds works and
could fit my needs.

I want to realize a system where i could dinamically register and
unregister services and all of these services implements the same
interface ( for example IStandardService ).

Then suppose for examples i've two bundle A and B and each of one
provide an implementation of this interface ( AServiceImpl, BServiceImpl).

Actually i've declared a ComponentFactory in bundle A, and a
ComponentFactory in bundle B and each of these factory provide to create
instances of AserviceImpl and of BServiceImpl.

I've used a component factory because i could have both the case:

1 - Different implementations of the same interface
2 - Different instances of the same implementation ( but with different
properties ) for example a custom identifier for instances.

Is this the right approach??? This question is because i've read that
it's possible to have both ComponentFactory and ServiceFactory.

I've buyed the two books about OSGi, and read the free one from neil,
but i'm still having not clear these aspect.

Is there a clear tutorial on DS ComponentFactory/ServiceFactory usage???

Thanks
Andrea Zoppello