Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] How I can get the generic-server instance created by extension?

Hi Pavel,

Samolisov Pavel wrote:
Hello, Folks!

I have made the eclipse plugin and have defined the extension point
"org.eclipse.ecf.server.generic.configuration"

<extension
         point="org.eclipse.ecf.server.generic.configuration">
      <connector
            discovery="true"
            hostname="localhost"
            keepAlive="30000"
            port="4280">
         <group
               name="mygroup">
         </group>
      </connector>
   </extension>

Server have been created and works fine! But I have a problem: How can I
get this server instance in a plugin's activator? For example, I want to
register remote service by this server (using Remote Services API).

Unfortunately, this method of creating and initializing generic servers (i.e. this extension point) was implemented rather long ago (before ECF had an IContainerManager service), and so it doesn't currently support access via the IContainerManager service (which would be the normal method...i.e. in your own code you could get the IContainerManager via OSGi service lookup, followed by your code:

IContainer[] allContainers = containerManager.getAllContainers();
// look through array to find the one you are interested in...or use containerManager.getContainer(...) to get the one you are interested in IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) myContainer.getAdapter(IRemoteServiceContainerAdapter.class);
// use the adapter to register your remote service

BUT, like I said this old code does not currently support the containerManager...and so containerManager.getAllContainers() will not find the ones created via the configuration extension point.

This support would be easy to add, however, and I would be happy to do so. Please open an enhancement request and I will address it. But it isn't currently in existing/released code (i.e. in ECF 3.1).

Another way to do this with existing code, however, would be to create your own subclass of AbstractGenericServer and parse a config file yourself using the ServerConfigParser to create and config server instances.

But please LMK about adding support for containerManager in the code that reads the configuration extension point. Actually, I would appreciate an enhancement request in any event.

Scott




Back to the top