Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] ECF Spring Support

Hi Scott,

I have studied ECF and start to implement Spring support for ECF for remoting service. I can manage the sample org.eclipse.ecf.examples.remoteservices.hello.consumer with Spring DM. So you need NOT use ServiceTracker to get remoting service. Full Declarative Services is used. Let's me explain you how it works.

I have a thread HelloClientThread which poll the IHello service by ECF remoting :

package org.eclipse.ecf.examples.remoteservices.hello.consumer2;

import org.eclipse.ecf.examples.remoteservices.hello.IHello;

public class HelloClientThread extends Thread{

    private IHello hello;
   
    public void setHello(IHello hello) {
        this.hello = hello;
    }
   
    @Override
    public void run() {
        while (true) {           
            try {               
                hello.hello("HelloClientThread");
                Thread.sleep(1000);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

The IHello service is injected by Spring Container. Here the XMl Spring configuration :

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi"
    xsi:schemaLocation="http://www.springframework.org/schema/osgi 
       http://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd
       http://www.springframework.org/schema/beans  
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">


    <osgi:reference id="containerManager"
        interface="org.eclipse.ecf.core.IContainerManager" timeout="1000" />

    <bean class="org.springframework.remoting.ecf.LocalContainerFactoryBean">
        <property name="containerManager" ref="containerManager"></property>
        <property name="containerType" value="ecf.generic.client"></property>
    </bean>

    <osgi:reference id="helloService"
        interface="org.eclipse.ecf.examples.remoteservices.hello.IHello"
        timeout="1000" cardinality="0..1"
        filter="(osgi.remote=*)" />
       
    <bean id="helloClient"
        class="org.eclipse.ecf.examples.remoteservices.hello.consumer2.HelloClientThread"
        init-method="start" destroy-method="interrupt">
        <property name="hello" ref="helloService"></property>       
    </bean>

</beans> 

Here the explanation about this file :

1. <osgi:reference id="containerManager"
        interface="org.eclipse.ecf.core.IContainerManager" timeout="1000" />
Retrieve IContainerManager from OSGi service registry. This line avoid to do

IContainerManager containerManager = getContainerManagerService();

which it use ServiceTracker to retrieve IContainerManager.

2. <bean class="org.springframework.remoting.ecf.LocalContainerFactoryBean">
        <property name="containerManager" ref="containerManager"></property>
        <property name="containerType" value="ecf.generic.client"></property>
    </bean>

It define a LocalContainerFactoryBean which is Spring FactoryBean which create the IContainer by using containerManager with type "ecf.generic.client" filled by <property name="containerType" value="ecf.generic.client"></property>

LocalContainerFactoryBean is a class I have implemented which create a IContainer by using .the containerManager and containerType information.

3. <osgi:reference id="helloService"
        interface="org.eclipse.ecf.examples.remoteservices.hello.IHello"
        timeout="1000" cardinality="0..1"
        filter="(osgi.remote=*)" />

Retrieve IHello servive registered into OSGi resgistry (by ECF container if i have understand). cardinality="0..1" is very important because the first time the IHello is not avaible into registry services.

4. <bean id="helloClient"
        class="org.eclipse.ecf.examples.remoteservices.hello.consumer2.HelloClientThread"
        init-method="start" destroy-method="interrupt">
        <property name="hello" ref="helloService"></property>       
    </bean>

Instanciate the Thread HelloClientThread and inject the IHello service into this thread and start the Thread.

My work is very basic (I have not managed future IRemoteService like the example), but you can manage basic remoting services.

What do you think about that? Do you like? If you like I could send you my (little) work and I will be happy to tchat with you to perform Spring support someone could explained me more feature about ECF.

Regards Angelo

2010/1/31 Angelo zerr <angelo.zerr@xxxxxxxxx>
Hi Scott,

Thank a lot for your answer!

You are rigth, Spring DM is based on OSGi service registry/service. I like Spring because you can manage  your  application layers, like DAO (Dabatase Access), Services Remoting, OSGi services with declarative mean (with XML bean Spring). Declare your exporting/importing services with Spring (and Spring DM) is very cool, because you could change the Remoting type (HTTP, Hessain, ECF...) at runtime (without stop server and client).

I will try to study ECF and if I can, I will try to see if we can develop Spring Support for ECF like HTTP Invoker.

Regards Angelo


2010/1/31 Scott Lewis <slewis@xxxxxxxxxxxxx>

Hi Angelo,

Angelo zerr wrote:
Hi ECF Team,

I'm working on Dynaresume Project <http://code.google.com/p/dynaresume/> which is RCP application with Spring Dynamic Module <http://www.springsource.org/osgi>. If you are frensh and if you are interested I have explained how develop RCP application with Spring Dynamic Module into my blog at http://angelozerr.wordpress.com/.

Today we are using Spring remoting with HTTP Invoker <http://static.springsource.org/spring/docs/2.5.x/reference/remoting.html#remoting-httpinvoker> to manage remoting between Client and Serveur. ECF seems very powerfull and I would like study if we can use it, but I would like use Spring to use it in order to declare service into Spring bean.


So my question is "Are you planned to develop ECF Spring Support?" Do you think it's easy to develop that?

We don't have any specific plans to add Spring support to ECF at this time.  This is no reflection on our desire to support Spring, but rather simply a reflection of the fact that the ECF project is extremely resource limited right now, and cannot undertake anything beyond what we've already committed to doing in our project plan [1].

However, I believe that given our recently announced [2] support for the OSGi 4.2 remote services specification, and the fact that Spring DM is based fundamentally on the OSGi service registry/service standards, my belief/suspicion is that Spring DM and ECF 3.2+ should work together very effectively...without any further explicit support from ECF.  That is, I believe the OSGi 4.2 remote services support should/will provide a good degree of integration by itself.

Further, the recently announced Virgo project [3], does explicitly mention ECF as a target project for integration, and so further integration may come naturally out of that from the Virgo team.

Finally, if others (e.g. you and/or others in the community) would like to contribute more explicit support or changes for Spring to ECF then we are happy to incorporate such contributions into ECF itself where needed.  Or, if you would like to supporting such an effort directly (e.g. by supporting one or more existing committers to do such work), then again we would be happy to do that.

Thanks,

Scott

[1] http://www.eclipse.org/projects/project-plan.php?projectid=rt.ecf
[2] http://eclipseecf.blogspot.com/2010/01/osgi-remote-services-from-ecf.html
[3] http://www.eclipse.org/proposals/virgo/


Thank a lot.

Regards Angelo
------------------------------------------------------------------------

_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev
 

_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev



Back to the top