use of org.qi4j.api.service.ServiceUnavailableException in project qi4j-sdk by Qi4j.
the class ImportedServiceReferenceInstance method getInstance.
private T getInstance() throws ServiceImporterException {
// DCL that works with Java 1.5 volatile semantics
if (serviceInstance == null) {
synchronized (this) {
if (serviceInstance == null) {
serviceInstance = serviceModel.<T>importInstance(module);
instance = serviceInstance.instance();
try {
activation.activate(serviceModel.newActivatorsInstance(module), serviceInstance, new Runnable() {
@Override
public void run() {
active = true;
}
});
} catch (Exception e) {
serviceInstance = null;
throw new ServiceUnavailableException("Could not activate service " + serviceModel.identity(), e);
}
}
}
}
return instance;
}
Aggregations