use of org.eclipse.ecf.discovery.IDiscoveryAdvertiser in project ecf by eclipse.
the class ZooDiscoveryTest method getDiscoveryAdvertiser.
protected IDiscoveryAdvertiser getDiscoveryAdvertiser() {
final IDiscoveryAdvertiser adapter = (IDiscoveryAdvertiser) this.container.getAdapter(IDiscoveryAdvertiser.class);
// $NON-NLS-1$
assertNotNull("Adapter must not be null", adapter);
return adapter;
}
use of org.eclipse.ecf.discovery.IDiscoveryAdvertiser in project ecf by eclipse.
the class Activator method getAdvertiser.
public IDiscoveryAdvertiser getAdvertiser() {
if (advertiserTracker == null) {
advertiserTracker = new ServiceTracker(this.context, IDiscoveryAdvertiser.class.getName(), null);
advertiserTracker.open();
}
try {
return (IDiscoveryAdvertiser) advertiserTracker.waitForService(DISCOVERY_TIMEOUT);
} catch (InterruptedException e) {
// $NON-NLS-1$
log("getAdvertiser", "Cannot get IDiscoveryAdvertiser", e);
}
return null;
}
use of org.eclipse.ecf.discovery.IDiscoveryAdvertiser in project ecf by eclipse.
the class Activator method getDiscoveryAdvertiser.
public IDiscoveryAdvertiser getDiscoveryAdvertiser(String containerUnderTest) {
advertiserTracker.open();
final ServiceReference[] serviceReferences = advertiserTracker.getServiceReferences();
if (serviceReferences != null) {
for (int i = 0; i < serviceReferences.length; i++) {
ServiceReference sr = serviceReferences[i];
if (containerUnderTest.equals(sr.getProperty(IDiscoveryAdvertiser.CONTAINER_NAME))) {
return (IDiscoveryAdvertiser) advertiserTracker.getService(sr);
}
}
}
return null;
}
use of org.eclipse.ecf.discovery.IDiscoveryAdvertiser 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(final BundleContext context) throws Exception {
final ServiceReference configAdminServiceRef = context.getServiceReference(ConfigurationAdmin.class.getName());
if (configAdminServiceRef == null) {
System.err.println("You don't have config admin deployed. Some tests will fail that require configuration!");
return;
}
final ConfigurationAdmin configAdmin = (ConfigurationAdmin) context.getService(configAdminServiceRef);
Configuration config = configAdmin.createFactoryConfiguration(DnsSdTestHelper.ECF_DISCOVERY_DNSSD + ".locator", null);
Dictionary properties = new Hashtable();
properties.put(IDnsSdDiscoveryConstants.CA_SEARCH_PATH, new String[] { DnsSdTestHelper.DOMAIN });
properties.put(IDnsSdDiscoveryConstants.CA_RESOLVER, DnsSdTestHelper.DNS_RESOLVER);
properties.put(IDnsSdDiscoveryConstants.CA_TSIG_KEY, DnsSdTestHelper.TSIG_KEY);
properties.put(IDnsSdDiscoveryConstants.CA_TSIG_KEY_NAME, DnsSdTestHelper.TSIG_KEY_NAME);
config.update(properties);
String filter = "(" + Constants.SERVICE_PID + "=" + config.getPid() + ")";
// add the service listener
locListener = new ServiceListener() {
public void serviceChanged(ServiceEvent event) {
switch(event.getType()) {
case ServiceEvent.REGISTERED:
ServiceReference serviceReference = event.getServiceReference();
discoveryLocator = (IDiscoveryLocator) context.getService(serviceReference);
synchronized (locLock) {
locLock.notifyAll();
}
}
}
};
context.addServiceListener(locListener, filter);
// try to get the service initially
ServiceReference[] references = context.getServiceReferences(IDiscoveryLocator.class.getName(), filter);
if (references != null) {
for (int i = 0; i < references.length; ) {
ServiceReference serviceReference = references[i];
discoveryLocator = (IDiscoveryLocator) context.getService(serviceReference);
synchronized (locLock) {
locLock.notifyAll();
}
}
}
// advertiser
config = configAdmin.createFactoryConfiguration(DnsSdTestHelper.ECF_DISCOVERY_DNSSD + ".advertiser", null);
properties = new Hashtable();
properties.put(IDnsSdDiscoveryConstants.CA_SEARCH_PATH, new String[] { DnsSdTestHelper.DOMAIN });
properties.put(IDnsSdDiscoveryConstants.CA_RESOLVER, DnsSdTestHelper.DNS_RESOLVER);
properties.put(IDnsSdDiscoveryConstants.CA_TSIG_KEY, DnsSdTestHelper.TSIG_KEY);
properties.put(IDnsSdDiscoveryConstants.CA_TSIG_KEY_NAME, DnsSdTestHelper.TSIG_KEY_NAME);
config.update(properties);
filter = "(" + Constants.SERVICE_PID + "=" + config.getPid() + ")";
// add the service listener
advListener = new ServiceListener() {
public void serviceChanged(ServiceEvent event) {
switch(event.getType()) {
case ServiceEvent.REGISTERED:
ServiceReference serviceReference = event.getServiceReference();
discoveryAdvertiser = (IDiscoveryAdvertiser) context.getService(serviceReference);
synchronized (advLock) {
advLock.notifyAll();
}
}
}
};
context.addServiceListener(advListener, filter);
// try to get the service initially
references = context.getServiceReferences(IDiscoveryAdvertiser.class.getName(), filter);
if (references != null) {
for (int i = 0; i < references.length; ) {
ServiceReference serviceReference = references[i];
discoveryAdvertiser = (IDiscoveryAdvertiser) context.getService(serviceReference);
synchronized (advLock) {
advLock.notifyAll();
}
}
}
}
use of org.eclipse.ecf.discovery.IDiscoveryAdvertiser in project ecf by eclipse.
the class AbstractMetadataFactoryTest method getDiscoveryAdvertiser.
protected IDiscoveryAdvertiser getDiscoveryAdvertiser() {
ServiceTracker serviceTracker = new ServiceTracker(Activator.getDefault().getContext(), IDiscoveryAdvertiser.class.getName(), null);
serviceTracker.open();
IDiscoveryAdvertiser result = (IDiscoveryAdvertiser) serviceTracker.getService();
serviceTracker.close();
return result;
}
Aggregations