Add modules to Bazel build
cli
core
incubator/rpc
pipelines/basic
protocols/netconf
protocols/openflow
protocols/rest
Change-Id: I165b94a04ba893d97d944e5deb2746f54566503b
diff --git a/utils/osgi/src/main/java/org/onlab/osgi/DefaultServiceDirectory.java b/utils/osgi/src/main/java/org/onlab/osgi/DefaultServiceDirectory.java
index 36883fe..40894e3 100644
--- a/utils/osgi/src/main/java/org/onlab/osgi/DefaultServiceDirectory.java
+++ b/utils/osgi/src/main/java/org/onlab/osgi/DefaultServiceDirectory.java
@@ -15,6 +15,7 @@
*/
package org.onlab.osgi;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
@@ -32,13 +33,16 @@
* @return service implementation
*/
public static <T> T getService(Class<T> serviceClass) {
- BundleContext bc = FrameworkUtil.getBundle(serviceClass).getBundleContext();
- if (bc != null) {
- ServiceReference<T> reference = bc.getServiceReference(serviceClass);
- if (reference != null) {
- T impl = bc.getService(reference);
- if (impl != null) {
- return impl;
+ Bundle bundle = FrameworkUtil.getBundle(serviceClass);
+ if (bundle != null) {
+ BundleContext bc = bundle.getBundleContext();
+ if (bc != null) {
+ ServiceReference<T> reference = bc.getServiceReference(serviceClass);
+ if (reference != null) {
+ T impl = bc.getService(reference);
+ if (impl != null) {
+ return impl;
+ }
}
}
}