}
@Uri(method = HttpMethod.GET, value = "/services/bundle/{bundleid}/{serviceIndex}")
public Map<String, Object> service(@UriVariable final long bundleid, @UriVariable int serviceIndex) {
final List<TemplateBundle> servicesByBundle = getTemplateServicesByBundle();
TemplateServiceReference serviceReferences = null;
for (TemplateBundle templateBundle : servicesByBundle) {
if (templateBundle.getBundleId() == bundleid) {
serviceReferences = templateBundle.getServices().get(serviceIndex);
break;
}
}
final Object context;
if (serviceReferences != null) {
@SuppressWarnings("unchecked")
final ServiceReference<Object> serviceReference = serviceReferences.getServiceReference();
context = bundleHelper.getBundle(bundleid).getBundleContext().getService(serviceReference);
if (context instanceof ApplicationContext) {
ApplicationContext applicationContext = (ApplicationContext)context;
final String[] definitionNames = applicationContext.getBeanDefinitionNames();
final Map<String,String> beans = new HashMap<String, String>(definitionNames.length);