Subclasses of BaseBundleActivator can query the properties of
an imported service using the methods
getImportedServicePropertyKeys(String) and
getImportedServiceProperty(String, Object). For example:
protected void activate() {
String[] keys = getImportedServicePropertyKeys(CounterService.SERVICE_NAME);
String key;
Object value;
System.out.println("CounterService Properties:");
for (int i = 0; i < keys.length; i++) {
key = keys [ i ];
value = getImportedServiceProperty(CounterService.SERVICE_NAME, key);
System.out.println(key + " = " + value);
}
}
getImportedServicePropertyKeys(String) is
used to retrieve a String[] of property keys for an
imported service. Of course this is not necessary if the property keys
are already known.
getImportedServiceProperty(String, String)
is used to retrieve the value of an imported service property matching
the specified key.
Copyright © 2001, 2007 IBM Corporation and others. All Rights Reserved.