Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ecf-dev] RemoteServices: first call to getRemoteServiceReferences return nothing

I have a problem of initialization with the getRemoteServiceReferences.
I am playing with Eclipse 3.3 and ECF 1.1.

Here are my plugins :

- Plugin1 :
   - start the server in a startup extension
       ID serverID = IDFactory.getDefault().createStringID("ecftcp://localhost:3282/server");
       Object[] args = new Object[] { serverID };
       server = ContainerFactory.getDefault().createContainer(" ecf.generic.server", args);
  - defines the IConcat interface (the interface of the service that will be published

- Plugin2 :
  - depends on Plugin1
  - publishes a service in an action extension
       IContainer clientOne = ContainerFactory.getDefault().createContainer("ecf.generic.client");
       ID serverID = IDFactory.getDefault().createStringID("ecftcp://localhost:3282/server");
       clientOne.connect(serverID, null);
       IRemoteServiceContainerAdapter remoteContainerOne = (IRemoteServiceContainerAdapter) clientOne.getAdapter(IRemoteServiceContainerAdapter.class);
       IRemoteServiceRegistration remoteServiceRegistration = remoteContainerOne.registerRemoteService(new String[] { IConcat.class.getName() }, new ConcatImpl(), null);

- Plugin3:
  - depends on Plugin1
  - in an action extension, look for the published service and call it
       IContainer clientTwo = ContainerFactory.getDefault().createContainer("ecf.generic.client");
       ID serverID = IDFactory.getDefault().createStringID("ecftcp://localhost:3282/server");
       clientTwo.connect(serverID, null);
       IRemoteServiceContainerAdapter remoteContainerTwo = (IRemoteServiceContainerAdapter) clientTwo.getAdapter(IRemoteServiceContainerAdapter.class);
       Thread.sleep (1000);
       IRemoteServiceReference[] refs = remoteContainerTwo.getRemoteServiceReferences(null, null, null);
       if (refs.length==0) {
           System.out.println("Service not found");
       IRemoteService remoteService = remoteContainerTwo.getRemoteService(refs[0]);
       IConcat remoteConcat=(IConcat)remoteService.getPoxy();
       String result =  remoteConcat.concat("Eclipse "," is cool");
       System.out.println("TEST RESULT (asynch): " + result);

If I put these 3 plugins inside 1 Eclipse, everything works fine, I can publish and call the service.

But when I put in 1 Eclipse Plugin1 and 2 and in another Eclipse Plugin1 and 3 then
the first call to the service always returns "service not found", ie getRemoteServiceReferences returns an empty array.
Then following calls works fine.

As a workaround I have added inside Plugin1 startup extension the creation of an useless client :
           ID serverID = IDFactory.getDefault().createStringID("ecftcp://localhost:3282/server");
           IContainer client = ContainerFactory.getDefault().createContainer("ecf.generic.client");
           client.connect(serverID, null);
           IRemoteServiceContainerAdapter remoteContainerTwo = (IRemoteServiceContainerAdapter) client.getAdapter(IRemoteServiceContainerAdapter.class);
           IRemoteServiceReference[] refs = remoteContainerTwo.getRemoteServiceReferences(null, null, null);

Is there something that I missed ? An "init" method ? Or is it a bug ?

Thanks for your help

Back to the top