Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Communications Framework (ECF) » Getting the running r-OSGi port number before registering a service
Getting the running r-OSGi port number before registering a service [message #624036] Mon, 08 September 2008 12:20
Anders Forsell is currently offline Anders ForsellFriend
Messages: 125
Registered: July 2009
Senior Member
I have a simple client-server application running where a remote service is
registered by a plug-in in one r-OSGi environment:

ID serverID =
server = ContainerFactory.getDefault().createContainer("ecf.r_osgi.peer ",
new Object[] {serverID});
IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter)
adapter.registerRemoteService(new String[]
{IConcatService.class.getName()}, new IConcatService(){
public String concat(String string1, String string2) {
return string1 + string2;
};}, new HashTable());

.... and the client which is running in another r-OSGi environment (different
process same machine) uses the service like this:
ID serverId =
IContainer client =
ContainerFactory.getDefault().createContainer("ecf.r_osgi.peer ", new
Object[] {});
client.connect(serverId, null);
IRemoteServiceContainerAdapter remote = (IRemoteServiceContainerAdapter)
IRemoteServiceReference[] refs = remote.getRemoteServiceReferences(null,
Assert.isTrue(refs.length > 0, "The service has not been started");
IRemoteService service = remote.getRemoteService(refs[0]);
IConcatService serviceProxy =(IConcatService) service.getProxy();
String r = serviceProxy.concat("Anders", "Forsell");

My problem is that if the port 9278 is busy (for example when multiple
r-OSGi servers are running), the next available port will be used by r-OSGi
(ex. 9279).
Thus my "hardcoded" port will not be valid.

How can I determine which port that has been assigned to the running r-OSGi
environment before registering the service ?
I have tried removing the port from the createStringID call like this:
ID serverID =
.... but then the default value of '9278' will be used even if the
environment is using another port.

Previous Topic:ECF conference call RESCHEDULED
Next Topic:How to publish remote services (r-osgi) automatically / discover peers ?
Goto Forum:

Current Time: Fri May 25 07:24:50 GMT 2018

Powered by FUDForum. Page generated in 0.01803 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top