use of org.motechproject.mds.exception.entity.ServiceNotFoundException in project motech by motech.
the class DataServiceHelper method getDataService.
/**
* Retrieves {@link org.motechproject.mds.service.MotechDataService} implementation for the
* given entity class. It will throw {@link org.motechproject.mds.exception.entity.ServiceNotFoundException}, in
* case a service for the given entity class cannot be found.
*
* @param bundleContext context of a bundle
* @param entityClass fully qualified class name of an entity
* @return generated {@link org.motechproject.mds.service.MotechDataService} implementation
*/
public static MotechDataService getDataService(BundleContext bundleContext, String entityClass) {
String interfaceName = MotechClassPool.getInterfaceName(entityClass);
MotechDataService dataService = OSGiServiceUtils.findService(bundleContext, interfaceName);
if (dataService == null) {
throw new ServiceNotFoundException(interfaceName);
}
return dataService;
}
use of org.motechproject.mds.exception.entity.ServiceNotFoundException in project motech by motech.
the class MdsDummyDataGeneratorImpl method getService.
@Override
public MotechDataService getService(BundleContext bundleContext, String className) {
String interfaceName = MotechClassPool.getInterfaceName(className);
ServiceReference ref = bundleContext.getServiceReference(interfaceName);
if (ref == null) {
throw new ServiceNotFoundException(interfaceName);
}
return (MotechDataService) bundleContext.getService(ref);
}
Aggregations