Search in sources :

Example 1 with ServiceUnavailableException

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;
}
Also used : ServiceUnavailableException(org.qi4j.api.service.ServiceUnavailableException) ServiceImporterException(org.qi4j.api.service.ServiceImporterException) ActivationException(org.qi4j.api.activation.ActivationException) PassivationException(org.qi4j.api.activation.PassivationException) ServiceUnavailableException(org.qi4j.api.service.ServiceUnavailableException)

Aggregations

ActivationException (org.qi4j.api.activation.ActivationException)1 PassivationException (org.qi4j.api.activation.PassivationException)1 ServiceImporterException (org.qi4j.api.service.ServiceImporterException)1 ServiceUnavailableException (org.qi4j.api.service.ServiceUnavailableException)1