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);