use of org.motechproject.mds.rest.MdsRestFacade in project motech by motech.
the class MdsRestFacadeRetriever method getRestFacade.
public MdsRestFacade getRestFacade(String entityName, String moduleName, String namespace) {
String restId = ClassName.restId(entityName, moduleName, namespace);
MdsRestFacade restFacade = null;
try {
String filter = String.format("(org.eclipse.gemini.blueprint.bean.name=%s)", restId);
Collection<ServiceReference<MdsRestFacade>> refs = bundleContext.getServiceReferences(MdsRestFacade.class, filter);
if (refs != null && refs.size() > 1 && LOGGER.isWarnEnabled()) {
LOGGER.warn("More then one Rest Facade matching for entityName={}, module={}, namespace={}. " + "Using first one available.", entityName, moduleName, namespace);
}
if (refs != null && refs.size() > 0) {
ServiceReference<MdsRestFacade> ref = refs.iterator().next();
restFacade = bundleContext.getService(ref);
}
} catch (InvalidSyntaxException e) {
throw new IllegalArgumentException("Invalid Syntax for Rest Facade retrieval", e);
}
if (restFacade == null) {
throw new RestNotSupportedException(entityName, moduleName, namespace);
}
return restFacade;
}
Aggregations