Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] Incubator request for Extensions/Services Integration work

+1

Great! This is a very interesting topic.

Within Riena we are currently using a simple to use ´framework´ to inject services and extensions
into objects (pojos). Our approach is code based and looks like this.

Inject.service("clazz1").into(target).andStart(context)
Inject.service("clazz2").useFilter(filter).into(target).bind("register").unbind("unregister").andStart(context)
Inject.service("clazz3").useRanking().into(target).bind("register").unbind("unregister").andStart(context)

where ´target´ is the pojo that gets a service/s injected. When services come and go they will be injected into or removed from the pojos. The method names for injecting/removing can be specified with the bind() and unbind() methods. If they are not defined default method names are assumed.

With
Inject.extension("point1").into(target).andStart(context)
Inject.extension("point2").useType(interface).into(target).bind("configure").andStart(context)
Inject.extension("point3").expectExactly(1).into(target).andStart()

extension points get injected into pojos as instances of an interface defined by useType(). If the interface is not defined explicitly it will be retrieved with reflection from the bind method. The interface needs only to declare the getters. Dynamic proxies will be created for this interface which map the data from the extensions. A few simple rules are used for the mapping from extension to the properties (lightweight xml/java mapping).

The source code is available in org.eclipse.riena package org.eclipse.riena.core.injector. Unit tests are available in
org.eclipse.riena.tests packages org.eclipse.riena.core.extension/service.

Tschüß,
Stefan


Neil Bartlett wrote:
Hello,

I have been doing some investigative work recently in the area of
integrating extensions with OSGi services. As a result of this, I have
developed a small framework for dynamically injecting services into
extension objects according to metadata defined via the extension
registry. As a very simple example, suppose we have an extension
object (e.g. a ViewPart) which has a method
setLogReader(LogReaderService). We can declare an "injected bean"
extension as follows:

    <extension point="...injectedBeans">
        <bean id="logReaderView"
              class="org...LogReaderView">
            <injectSingle interface="org.osgi.service.log.LogReaderService"
                          set="setLogReader"/>
        </bean>
    </extension>

And then the actual view extension as:

    <extension point="org.eclipse.ui.views">
        <view class="org...InjectedExtensionFactory:logReaderView"
              name="Log Reader"/>
    </extension>

This results in all objects instantiated from the log view extension
being dynamically injected with the log reader service as it becomes
available (and un-injected when it goes away).

I would like to request a work area under the Equinox incubator as a
home for this code so that others can test it and experiment with this
and other approaches to the extensions/services integration problem.

Regards,
Neil
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev



Back to the top