Merge "Removing { } from NormalizedNodeJsonBodyWriter"
[controller.git] / opendaylight / networkconfiguration / neutron / northbound / src / main / java / org / opendaylight / controller / networkconfig / neutron / northbound / NeutronUtil.java
1 package org.opendaylight.controller.networkconfig.neutron.northbound;
2
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;
8
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;
14         try {
15             BundleContext bCtx = FrameworkUtil.getBundle(bundle.getClass())
16                     .getBundleContext();
17
18             ServiceReference<?>[] services = null;
19                 services = bCtx.getServiceReferences(clazz.getName(),
20                         null);
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]);
25                 }
26             }
27         } catch (Exception e) {
28             logger.error("Instance reference is NULL");
29         }
30         return instances;
31     }
32 }