1 package org.opendaylight.neutron.northbound.api;
3 import org.osgi.framework.BundleContext;
4 import org.osgi.framework.FrameworkUtil;
5 import org.osgi.framework.ServiceReference;
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
9 public class NeutronUtil {
10 private static final Logger logger = LoggerFactory
11 .getLogger(NeutronUtil.class);
12 public static Object[] getInstances(Class<?> clazz,Object bundle) {
13 Object instances[] = null;
15 BundleContext bCtx = FrameworkUtil.getBundle(bundle.getClass())
18 ServiceReference<?>[] services = null;
19 services = bCtx.getServiceReferences(clazz.getName(),
21 if (services != null) {
22 instances = new Object[services.length];
23 for (int i = 0; i < services.length; i++) {
24 instances[i] = bCtx.getService(services[i]);
27 } catch (Exception e) {
28 logger.error("Instance reference is NULL");