Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ecf-dev] Need help to improve support Spring for ECF

Hi ECF team,

I don't know if you recall me. I'm Angelo ZERR who has started to develop the Spring support for ECF. I would like improve it and Scott suggested me to post my questions on the ECF forum.
I start with my (little) improvment and finish with the problem with Spring-ECF.

1. Improvment

I have worked on Spring-ECF and here the description of my (little) improvment about the Spring-ECF samples :

* Use Spring 3.0 (instead-of 2.5.6)
* Use Spring EL to declare as JVM parameters teh containerType. For instance you can declarethis :


<bean class="org.eclipse.ecf.
springframework.ConsumerContainerFactoryBean">
        <property name="containerManager" ref="containerManager" />
        <property name="containerType" value="#{systemProperties['containerType']}" />
    </bean>

I mean

and the value of #{systemProperties['containerType']}" comes from containerType JVM Parameters. SO now I have several product as you (generic, r_osgi....)

* declare discoveryListenerRegistration and distributionListenerRegistration as your sample. It's a basic declaration :

<!-- Register proxy discovery listener to log the publish/unpublish of remote services.  -->   
    <bean id="discoveryListenerRegistration" class="org.eclipse.ecf.osgi.services.discovery.LoggingProxyDiscoveryListener" />

    <osgi:service ref="discoveryListenerRegistration"
        interface="org.eclipse.ecf.osgi.services.discovery.IProxyDiscoveryListener" >
    </osgi:service>

    <!-- Register proxy distribution listener to log the register/unregister of remote services. -->
    <bean id="distributionListenerRegistration" class="org.eclipse.ecf.osgi.services.distribution.LoggingProxyDistributionListener" />

    <osgi:service ref="distributionListenerRegistration"
        interface="org.eclipse.ecf.osgi.services.distribution.IProxyDistributionListener" >
    </osgi:service>

1. Spring-ECF problems

There is a problem  when the sample DM consumer start  org.eclipse.ecf.examples.remoteservices.hello.dm.consumer before sample DM host org.eclipse.ecf.examples.remoteservices.hello.dm.host (or another host).
This consumer sample force the targetID. It's done with in the ConsumerContainerFactoryBean :

protected IContainer createContainer() throws ContainerCreateException,
            ContainerConnectException {
        IContainer container = super.createBasicContainer();
        if (targetId != null) {
                container.connect(targetId, connectContext);

        }
        return container;
    }

When consumer start before server, connection can be done and container.connect(targetId, null); failed.

------------------------------------------------------------------------------------------------------

[log;+0200 2010.08.19 11:18:24:234;ERROR;org.eclipse.ecf.osgi.services.distribution;org.eclipse.core.runtime.Status[plugin=org.eclipse.ecf.osgi.services.distribution;code=4;message=org.eclipse.ecf.internal.osgi.services.distribution.DiscoveredServiceTrackerImpl:handleDiscoveredServiceAvailable:rsca=RemoteServiceContainer [containerID=StringID[celF/jvmYmvLAmxmnd3jHYq52xw=], container=org.eclipse.ecf.provider.generic.TCPClientSOContainer@1478a43, containerAdapter=org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject@1eec35],endpointId=StringID[ecftcp://localhost:3787/server],intf=org.eclipse.ecf.examples.remoteservices.hello.IHello. Connect error in getRemoteServiceReferences;severity4;exception=org.eclipse.ecf.core.ContainerConnectException: Exception during connection to ecftcp://localhost:3787/server;children=[]]]
org.eclipse.ecf.core.ContainerConnectException: Exception during connection to ecftcp://localhost:3787/server
    at org.eclipse.ecf.provider.generic.ClientSOContainer.connect(ClientSOContainer.java:176)
    at org.eclipse.ecf.provider.generic.SOContext.connect(SOContext.java:112)
    at org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject.connectToRemoteServiceTarget(RegistrySharedObject.java:242)
    at org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject.getRemoteServiceReferences(RegistrySharedObject.java:218)
    at org.eclipse.ecf.internal.osgi.services.distribution.DiscoveredServiceTrackerImpl.handleDiscoveredServiceAvailable(DiscoveredServiceTrackerImpl.java:247)
    at org.eclipse.ecf.internal.osgi.services.distribution.DiscoveredServiceTrackerImpl.access$4(DiscoveredServiceTrackerImpl.java:214)
    at org.eclipse.ecf.internal.osgi.services.distribution.DiscoveredServiceTrackerImpl$1.dispatchEvent(DiscoveredServiceTrackerImpl.java:103)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:337)
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(Unknown Source)
    at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at org.eclipse.ecf.provider.comm.tcp.SocketFactory.createSocket(SocketFactory.java:26)
    at org.eclipse.ecf.provider.comm.tcp.Client.connect(Client.java:181)
    at org.eclipse.ecf.provider.generic.ClientSOContainer.connect(ClientSOContainer.java:146)
    ... 8 more
------------------------------------------------------------------------------------------------------

If I start the host before the consumer it works well.

If I remove the targetId, I don't call container.connect(targetId, null); and it works well.

So my question is what I must to do ? I could trty/catch the line container.connect(targetId, null);  (it works well) but is it a clean solution?
Thank a lot for your help.


I have noticed that HelloConsumerApplication you do that :

private void startLocalDiscoveryIfPresent() {
        Bundle[] bundles = bundleContext.getBundles();
        for(int i=0; i < bundles.length; i++) {
            if (bundles[i].getSymbolicName().equals("org.eclipse.ecf.osgi.services.discovery.local")) {
                try {
                    bundles[i].start();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }

Do you think it's interesting to add this code when Spring create the IContainer (into ConsumerContainerFactoryBean#createContainer() )?

When you will answer I will do a new patch that I send to ECF buzilla. If you see another improvment, don(t hesitate to tell me).

Thank a lot.

Regards Angelo

Back to the top