use of org.platformlayer.xaas.services.ServiceProvider in project platformlayer by platformlayer.
the class ServiceProviderHelpers method getModelSubclasses.
public <T extends ItemBase> List<ModelClass<? extends T>> getModelSubclasses(Class<T> parent) {
List<ModelClass<? extends T>> modelClasses = Lists.newArrayList();
for (ServiceInfo serviceInfo : serviceProviderDictionary.getAllServices()) {
ServiceType serviceType = new ServiceType(serviceInfo.serviceType);
ServiceProvider serviceProvider = serviceProviderDictionary.getServiceProvider(serviceType);
for (ModelClass<?> modelClass : serviceProvider.getModels().all()) {
Class<?> javaClass = modelClass.getJavaClass();
if (parent.isAssignableFrom(javaClass)) {
modelClasses.add((ModelClass<? extends T>) modelClass);
}
}
}
return modelClasses;
}
use of org.platformlayer.xaas.services.ServiceProvider in project platformlayer by platformlayer.
the class MetricsResource method getMetrics.
@POST
@Produces({ XML, JSON })
public MetricDataSource getMetrics(final MetricQuery query) throws RepositoryException, OpsException {
final ItemBase managedItem = getManagedItem();
final ServiceProvider serviceProvider = getServiceProvider();
OpsContextBuilder opsContextBuilder = objectInjector.getInstance(OpsContextBuilder.class);
final OpsContext opsContext = opsContextBuilder.buildTemporaryOpsContext(getServiceType(), getProjectAuthorization());
return OpsContext.runInContext(opsContext, new CheckedCallable<MetricDataSource, Exception>() {
@Override
public MetricDataSource call() throws Exception {
BindingScope bindingScope = BindingScope.push(managedItem, managedItem);
try {
MetricDataSource metrics = serviceProvider.getMetricValues(managedItem, query);
return metrics;
} finally {
bindingScope.pop();
}
}
});
}
use of org.platformlayer.xaas.services.ServiceProvider in project platformlayer by platformlayer.
the class ServiceResource method getExtensionsResource.
@Path("extensions")
public Object getExtensionsResource() throws Exception {
final ServiceProvider serviceProvider = getServiceProvider();
OpsContextBuilder opsContextBuilder = objectInjector.getInstance(OpsContextBuilder.class);
final OpsContext opsContext = opsContextBuilder.buildTemporaryOpsContext(getServiceType(), getProjectAuthorization());
Object extensionResource = OpsContext.runInContext(opsContext, new CheckedCallable<Object, Exception>() {
@Override
public Object call() throws Exception {
return serviceProvider.getExtensionResource();
}
});
if (extensionResource == null) {
raiseNotFound();
}
return extensionResource;
}
use of org.platformlayer.xaas.services.ServiceProvider in project platformlayer by platformlayer.
the class XaasResourceBase method getModelClass.
protected ModelClass<?> getModelClass() {
ServiceProvider serviceProvider = getServiceProvider();
if (serviceProvider == null) {
log.warn("Unknown service");
raiseNotFound();
}
ModelClass<?> modelClass = serviceProvider.getModels().find(getItemType());
if (modelClass == null) {
log.warn("Unknown itemtype: " + getItemType());
raiseNotFound();
}
return modelClass;
}
Aggregations