use of org.springframework.osgi.mock.MockServiceReference in project camel by apache.
the class CamelMockBundleContext method addServicePID.
private static void addServicePID(ServiceReference[] srs, String filter) {
for (ServiceReference sr : srs) {
if (sr instanceof MockServiceReference) {
Dictionary properties = new Hashtable();
String pid = filter.replace("(" + Constants.SERVICE_PID + "=", "").replace(")", "");
properties.put(Constants.SERVICE_PID, pid);
for (String key : sr.getPropertyKeys()) {
if (properties.get(key) == null) {
properties.put(key, sr.getProperty(key));
}
}
((MockServiceReference) sr).setProperties(properties);
}
}
}
use of org.springframework.osgi.mock.MockServiceReference in project camel by apache.
the class CamelMockBundleContext method getAllServiceReferences.
@SuppressWarnings({ "rawtypes", "unchecked" })
public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
// just simulate when the bundle context doesn't have right service reference
if (filter != null && filter.indexOf("name=test") > 0) {
return null;
}
MockServiceReference reference = new MockServiceReference(getBundle(), new String[] { clazz });
// setup the name property with the class name
Dictionary properties = new Hashtable();
properties.put("name", clazz);
reference.setProperties(properties);
return new ServiceReference[] { reference };
}
Aggregations