Hi Franck,
Franck Gasnier wrote:
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");
return;
}
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);
client.disconnect();
Is there something that I missed ? An "init" method ? Or is it a bug ?
I'm not sure yet.
You say that in your second client (the 'client' of the service) you
make this call:
IRemoteServiceReference[] refs =
remoteContainerTwo.getRemoteServiceReferences(null, null, null);
But the getRemoteServiceReference method requires a non-null value for
the second parameter...so it probably should be (and maybe is):
IRemoteServiceReference[] refs =
remoteContainerTwo.getRemoteServiceReferences(null,
IConcat.getClass().getName(), null);
Actually, I'm unclear on how a call to getRemoteServiceReferences(null,
null, null) could work. The impl always returns an empty array if the
second parameter is null.
But assuming that you do have the IConcat class in the code, then your
problem is something else. You say above that the plugin 1 is started
via 'startup' extension...is this the ECF startup extension or some
other? Also...you say that plugin 2 and plugin 3 are started via
action extension...I assume that you always run the plugin 2 action
before plugin 3 in tests.
Would you be willing to make these projects available to us? and I'll
try running in my workspace to see if we can diagnose the issue further?
Thanks,
Scott
Thanks for your help
Franck
_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ecf-dev
|