mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-30 15:57:11 +00:00
changes to placeholder identifier and (de)serialization
This commit is contained in:
1 parent
10f0b01576
commit
1ebed6373e
62 files changed
+812
-350
No files matched your search
+13
-2
@@ -25,6 +25,7 @@ public class CachedOsgiTypeBasedServiceFinder<ServiceT> implements ServiceTracke
|
||||
private final Map<String, ServiceT> services = new HashMap<>();
|
||||
private final BundleContext context;
|
||||
private Class<ServiceT> serviceType;
|
||||
private ServiceT fallback;
|
||||
|
||||
public CachedOsgiTypeBasedServiceFinder(Class<ServiceT> serviceType, BundleContext context) {
|
||||
this.serviceType = serviceType;
|
||||
@@ -35,8 +36,13 @@ public class CachedOsgiTypeBasedServiceFinder<ServiceT> implements ServiceTracke
|
||||
public ServiceT findService(String type) {
|
||||
ServiceT service = services.get(type);
|
||||
|
||||
if (service == null)
|
||||
throw new NoCorrespondingServiceRegisteredException("Could not find service", type, serviceType);
|
||||
if (service == null) {
|
||||
if (fallback != null) {
|
||||
return fallback;
|
||||
} else {
|
||||
throw new NoCorrespondingServiceRegisteredException("Could not find service", type, serviceType);
|
||||
}
|
||||
}
|
||||
|
||||
return service;
|
||||
}
|
||||
@@ -60,4 +66,9 @@ public class CachedOsgiTypeBasedServiceFinder<ServiceT> implements ServiceTracke
|
||||
String type = (String) reference.getProperty(TypeBasedServiceFinder.TYPE);
|
||||
services.remove(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFallbackService(ServiceT fallback) {
|
||||
this.fallback = fallback;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user