use of org.eclipse.ecf.core.IContainerManager in project ecf by eclipse.
the class Activator method start.
/*
* (non-Javadoc)
*
* @see
* org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext
* )
*/
public void start(BundleContext context) throws Exception {
this.context = context;
// Create R-OSGi Container
IContainerManager containerManager = getContainerManagerService();
container = containerManager.getContainerFactory().createContainer("ecf.r_osgi.peer");
// Get remote service container adapter
IRemoteServiceContainerAdapter containerAdapter = (IRemoteServiceContainerAdapter) container.getAdapter(IRemoteServiceContainerAdapter.class);
// Register remote service
serviceRegistration = containerAdapter.registerRemoteService(new String[] { IHello.class.getName() }, new Hello(), null);
System.out.println("IHello RemoteService registered");
}
use of org.eclipse.ecf.core.IContainerManager in project ecf by eclipse.
the class AbstractEventAdminApplication method getContainerManager.
protected IContainerManager getContainerManager() {
if (containerManagerTracker == null) {
containerManagerTracker = new ServiceTracker(bundleContext, IContainerManager.class.getName(), null);
containerManagerTracker.open();
}
return (IContainerManager) containerManagerTracker.getService();
}
use of org.eclipse.ecf.core.IContainerManager in project ecf by eclipse.
the class Activator method getContainers.
/**
* @return array of containers.
*/
public IContainer[] getContainers() {
final ServiceTracker tracker = new ServiceTracker(context, IContainerManager.class.getName(), null);
tracker.open();
return ((IContainerManager) tracker.getService()).getAllContainers();
}
use of org.eclipse.ecf.core.IContainerManager in project ecf by eclipse.
the class Activator method getContainerManagerService.
private IContainerManager getContainerManagerService() {
if (containerManagerServiceTracker == null) {
containerManagerServiceTracker = new ServiceTracker(context, IContainerManager.class.getName(), null);
containerManagerServiceTracker.open();
}
return (IContainerManager) containerManagerServiceTracker.getService();
}
use of org.eclipse.ecf.core.IContainerManager in project ecf by eclipse.
the class Activator method start.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
this.context = context;
// 1. Create R-OSGi Container
IContainerManager containerManager = getContainerManagerService();
container = containerManager.getContainerFactory().createContainer("ecf.r_osgi.peer");
// 2. Get remote service container adapter
IRemoteServiceContainerAdapter containerAdapter = (IRemoteServiceContainerAdapter) container.getAdapter(IRemoteServiceContainerAdapter.class);
// 3. Lookup IRemoteServiceReference
IRemoteServiceReference[] helloReferences = containerAdapter.getRemoteServiceReferences(IDFactory.getDefault().createID(container.getConnectNamespace(), ROSGI_SERVICE_HOST), IHello.class.getName(), null);
Assert.isNotNull(helloReferences);
Assert.isTrue(helloReferences.length > 0);
// 4. Get remote service for reference
IRemoteService remoteService = containerAdapter.getRemoteService(helloReferences[0]);
// 5. Get the proxy
IHello proxy = (IHello) remoteService.getProxy();
// 6. Finally...call the proxy
proxy.hello("RemoteService Consumer");
// Call asynchronously via listener
callViaListener(remoteService);
}
Aggregations