diff options
author | Ryan D. Brooks | 2016-07-12 22:35:20 +0000 |
---|---|---|
committer | Ryan Brooks | 2016-07-13 21:24:40 +0000 |
commit | e6417b03edc65baad6e436100417882c41cc6a81 (patch) | |
tree | b2fde64e4096a021e3ef8f0d24daddc810fd2544 /plugins/org.eclipse.osee.framework.messaging | |
parent | 016859b2d1130897d4d546dfb20b96c2b2a630de (diff) | |
download | org.eclipse.osee-e6417b03edc65baad6e436100417882c41cc6a81.tar.gz org.eclipse.osee-e6417b03edc65baad6e436100417882c41cc6a81.tar.xz org.eclipse.osee-e6417b03edc65baad6e436100417882c41cc6a81.zip |
refactor: Replace redundant code with OsgiUtil.getService
Change-Id: I1e03a1e3b11c009df85b71477db62235d5d47435
Diffstat (limited to 'plugins/org.eclipse.osee.framework.messaging')
2 files changed, 4 insertions, 35 deletions
diff --git a/plugins/org.eclipse.osee.framework.messaging/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.messaging/META-INF/MANIFEST.MF index 107b9d26be1..50e56a9fc20 100644 --- a/plugins/org.eclipse.osee.framework.messaging/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.messaging/META-INF/MANIFEST.MF @@ -117,6 +117,7 @@ Import-Package: javax.jms, org.eclipse.core.runtime, org.eclipse.osee.framework.core.data, org.eclipse.osee.framework.core.exception, + org.eclipse.osee.framework.core.util, org.eclipse.osee.framework.jdk.core.type, org.eclipse.osee.framework.jdk.core.util, org.eclipse.osee.framework.jdk.core.util.xml, diff --git a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/ServiceUtility.java b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/ServiceUtility.java index dbd6f97e294..93821ec1ac7 100644 --- a/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/ServiceUtility.java +++ b/plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/ServiceUtility.java @@ -10,43 +10,11 @@ *******************************************************************************/ package org.eclipse.osee.framework.messaging.internal; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceReference; +import org.eclipse.osee.framework.core.util.OsgiUtil; public class ServiceUtility { public static ConsoleDebugSupport getConsoleDebugSupport() { - return getService(ConsoleDebugSupport.class); + return OsgiUtil.getService(ServiceUtility.class, ConsoleDebugSupport.class); } - - private static Class<ServiceUtility> getClazz() { - return ServiceUtility.class; - } - - private static <T> T getService(Class<T> clazz) { - BundleContext context = getContext(); - if (context == null) { - return null; - } - ServiceReference serviceReference = context.getServiceReference(clazz.getName()); - if (serviceReference == null) { - return null; - } - return (T) getContext().getService(serviceReference); - } - - private static <T> T[] getServices(Class<T> clazz) throws InvalidSyntaxException { - ServiceReference[] serviceReferences = getContext().getServiceReferences(clazz.getName(), null); - T[] data = (T[]) new Object[serviceReferences.length]; - for (int i = 0; i < serviceReferences.length; i++) { - data[i] = (T) getContext().getService(serviceReferences[i]); - } - return data; - } - - public static BundleContext getContext() { - return FrameworkUtil.getBundle(getClazz()).getBundleContext(); - } -} +}
\ No newline at end of file |