Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2016-07-12 18:35:20 -0400
committerRyan Brooks2016-07-13 17:24:40 -0400
commite6417b03edc65baad6e436100417882c41cc6a81 (patch)
treeb2fde64e4096a021e3ef8f0d24daddc810fd2544
parent016859b2d1130897d4d546dfb20b96c2b2a630de (diff)
downloadorg.eclipse.osee-e6417b03edc65baad6e436100417882c41cc6a81.tar.gz
org.eclipse.osee-e6417b03edc65baad6e436100417882c41cc6a81.tar.xz
org.eclipse.osee-e6417b03edc65baad6e436100417882c41cc6a81.zip
refactor: Replace redundant code with OsgiUtil.getService
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/AbstractWorkflowArtifact.java10
-rw-r--r--plugins/org.eclipse.osee.ats.mocks/src/org/eclipse/osee/ats/db/mocks/internal/OsgiUtil.java22
-rw-r--r--plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlHelper.java24
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/OsgiUtil.java31
-rw-r--r--plugins/org.eclipse.osee.framework.messaging/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.framework.messaging/src/org/eclipse/osee/framework/messaging/internal/ServiceUtility.java38
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java19
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/internal/ServiceUtil.java15
-rw-r--r--plugins/org.eclipse.osee.orcs.db.mock/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/OsgiUtil.java14
-rw-r--r--plugins/org.eclipse.osee.orcs.script.dsl.ui.integration/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.orcs.script.dsl.ui.integration/src/org/eclipse/osee/orcs/script/dsl/ui/integration/internal/OrcsObjectProviderImpl.java23
12 files changed, 36 insertions, 163 deletions
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/AbstractWorkflowArtifact.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/AbstractWorkflowArtifact.java
index 5fcb07880d..ada6ada8a6 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/AbstractWorkflowArtifact.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/workflow/AbstractWorkflowArtifact.java
@@ -18,7 +18,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
@@ -62,6 +61,7 @@ import org.eclipse.osee.framework.core.enums.PermissionEnum;
import org.eclipse.osee.framework.core.services.CmAccessControl;
import org.eclipse.osee.framework.core.services.HasCmAccessControl;
import org.eclipse.osee.framework.core.util.IGroupExplorerProvider;
+import org.eclipse.osee.framework.core.util.OsgiUtil;
import org.eclipse.osee.framework.core.util.Result;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -75,9 +75,6 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
import org.eclipse.osee.framework.skynet.core.relation.RelationManager;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
/**
* @author Donald G. Dunne
@@ -752,10 +749,7 @@ public abstract class AbstractWorkflowArtifact extends AbstractAtsArtifact imple
@Override
public CmAccessControl getAccessControl() {
- Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
- BundleContext context = bundle.getBundleContext();
- ServiceReference<?> reference = context.getServiceReference(CmAccessControl.class.getName());
- return (CmAccessControl) context.getService(reference);
+ return OsgiUtil.getService(getClass(), CmAccessControl.class);
}
public List<IAtsStateDefinition> getToStatesWithCompleteCancelReturnStates() throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.ats.mocks/src/org/eclipse/osee/ats/db/mocks/internal/OsgiUtil.java b/plugins/org.eclipse.osee.ats.mocks/src/org/eclipse/osee/ats/db/mocks/internal/OsgiUtil.java
index 04e9b60666..6befa3ec4c 100644
--- a/plugins/org.eclipse.osee.ats.mocks/src/org/eclipse/osee/ats/db/mocks/internal/OsgiUtil.java
+++ b/plugins/org.eclipse.osee.ats.mocks/src/org/eclipse/osee/ats/db/mocks/internal/OsgiUtil.java
@@ -29,22 +29,6 @@ public final class OsgiUtil {
// Utility class
}
- public static <T> T getService(Class<T> clazz) throws OseeCoreException {
- Bundle bundle = FrameworkUtil.getBundle(OsgiUtil.class);
- checkStarted(bundle);
-
- BundleContext context = bundle.getBundleContext();
- Assert.assertNotNull(context);
-
- ServiceReference<T> reference = context.getServiceReference(clazz);
- Assert.assertNotNull(String.format("Unable to find service [%s]", clazz), reference);
-
- T service = context.getService(reference);
- Assert.assertNotNull(String.format("Unable to find service instance for [%s]", clazz), service);
-
- return service;
- }
-
public static <T> T getService(Class<T> clazz, String filter, long waitTimeMillis) throws OseeCoreException {
Bundle bundle = FrameworkUtil.getBundle(OsgiUtil.class);
checkStarted(bundle);
@@ -98,11 +82,7 @@ public final class OsgiUtil {
public static ConfigurationAdmin getConfigAdmin() {
Bundle cmBundle = getBundleByName("org.eclipse.equinox.cm");
checkStarted(cmBundle);
- try {
- return getService(ConfigurationAdmin.class);
- } catch (Exception ex) {
- throw new OseeCoreException(ex.getCause(), "Error acquiring configuration admin");
- }
+ return org.eclipse.osee.framework.core.util.OsgiUtil.getService(OsgiUtil.class, ConfigurationAdmin.class);
}
private static void checkStarted(Bundle bundle) {
diff --git a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlHelper.java b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlHelper.java
index 1f1073e7a8..27c4e33871 100644
--- a/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlHelper.java
+++ b/plugins/org.eclipse.osee.framework.access/src/org/eclipse/osee/framework/access/internal/AccessControlHelper.java
@@ -11,12 +11,8 @@
package org.eclipse.osee.framework.access.internal;
import org.eclipse.osee.framework.core.services.IAccessControlService;
+import org.eclipse.osee.framework.core.util.OsgiUtil;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Conditions;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
public final class AccessControlHelper {
@@ -26,25 +22,9 @@ public final class AccessControlHelper {
// Utility class
}
- private static BundleContext getBundleContext() throws OseeCoreException {
- Bundle bundle = FrameworkUtil.getBundle(AccessControlHelper.class);
- Conditions.checkNotNull(bundle, "bundle");
- return bundle.getBundleContext();
- }
-
- private static <T> T getService(Class<T> clazz) throws OseeCoreException {
- BundleContext context = getBundleContext();
- Conditions.checkNotNull(context, "bundleContext");
- ServiceReference<T> reference = context.getServiceReference(clazz);
- Conditions.checkNotNull(reference, "serviceReference");
- T service = context.getService(reference);
- Conditions.checkNotNull(service, "service");
- return service;
- }
-
@Deprecated
public static AccessControlService getAccessControlService() throws OseeCoreException {
- IAccessControlService service = getService(IAccessControlService.class);
+ IAccessControlService service = OsgiUtil.getService(AccessControlHelper.class, IAccessControlService.class);
AccessControlService toReturn = null;
if (service instanceof AccessControlServiceProxy) {
toReturn = ((AccessControlServiceProxy) service).getProxiedObject();
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/OsgiUtil.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/OsgiUtil.java
index 88e27080c1..2922245264 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/OsgiUtil.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/OsgiUtil.java
@@ -12,13 +12,16 @@ package org.eclipse.osee.framework.core.util;
import java.util.logging.Level;
import org.eclipse.osee.framework.core.internal.Activator;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.logging.OseeLog;
-import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
/**
* @author Roberto E. Escobar
+ * @author Ryan D. Brooks
*/
public final class OsgiUtil {
@@ -36,17 +39,19 @@ public final class OsgiUtil {
}
}
- public static void close(ServiceRegistration<?> registration) {
- if (registration != null) {
- try {
- registration.unregister();
- } catch (Exception ex) {
- // OseeLog.log(Activator.class, Level.WARNING, ex);
- }
+ public static <T> T getService(Class<?> classFromBundle, Class<T> clazz) {
+ BundleContext context = FrameworkUtil.getBundle(classFromBundle).getBundleContext();
+ if (context == null) {
+ throw new OseeCoreException("BundleContext is null for " + classFromBundle);
}
- }
-
- public static void close(ServiceDependencyTracker tracker) {
- Lib.close(tracker);
+ ServiceReference<T> serviceReference = context.getServiceReference(clazz);
+ if (serviceReference == null) {
+ throw new OseeCoreException("ServiceReference is null for class" + clazz);
+ }
+ T service = context.getService(serviceReference);
+ if (service == null) {
+ throw new OseeCoreException("getService is null for class" + clazz);
+ }
+ return service;
}
}
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 107b9d26be..50e56a9fc2 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 dbd6f97e29..93821ec1ac 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
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java
index 8f93e1d184..8dfb28de34 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java
@@ -17,19 +17,16 @@ import org.eclipse.osee.cache.admin.CacheAdmin;
import org.eclipse.osee.framework.core.client.ClientSessionManager;
import org.eclipse.osee.framework.core.services.IOseeCachingService;
import org.eclipse.osee.framework.core.sql.OseeSql;
+import org.eclipse.osee.framework.core.util.OsgiUtil;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.AccessPolicy;
import org.eclipse.osee.framework.skynet.core.attribute.service.AttributeAdapterService;
import org.eclipse.osee.framework.skynet.core.event.OseeEventService;
import org.eclipse.osee.orcs.rest.client.OseeClient;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
public final class ServiceUtil {
@@ -37,20 +34,8 @@ public final class ServiceUtil {
// Utility class
}
- private static BundleContext getBundleContext() throws OseeCoreException {
- Bundle bundle = FrameworkUtil.getBundle(ServiceUtil.class);
- Conditions.checkNotNull(bundle, "bundle");
- return bundle.getBundleContext();
- }
-
private static <T> T getService(Class<T> clazz) throws OseeCoreException {
- BundleContext context = getBundleContext();
- Conditions.checkNotNull(context, "bundleContext");
- ServiceReference<T> reference = context.getServiceReference(clazz);
- Conditions.checkNotNull(reference, "serviceReference");
- T service = context.getService(reference);
- Conditions.checkNotNull(service, "service");
- return service;
+ return OsgiUtil.getService(ServiceUtil.class, clazz);
}
public static CacheAdmin getCacheAdmin() throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/internal/ServiceUtil.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/internal/ServiceUtil.java
index 327fd0a297..a290fd3cf1 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/internal/ServiceUtil.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/internal/ServiceUtil.java
@@ -14,17 +14,14 @@ import java.util.logging.Level;
import org.eclipse.core.runtime.Platform;
import org.eclipse.osee.account.rest.client.AccountClient;
import org.eclipse.osee.framework.core.services.IOseeCachingService;
+import org.eclipse.osee.framework.core.util.OsgiUtil;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.AccessPolicy;
import org.eclipse.osee.framework.ui.skynet.cm.IOseeCmService;
import org.eclipse.osee.orcs.rest.client.OseeClient;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.osgi.service.packageadmin.PackageAdmin;
public final class ServiceUtil {
@@ -34,15 +31,7 @@ public final class ServiceUtil {
}
private static <T> T getService(Class<T> clazz) throws OseeCoreException {
- Bundle bundle = FrameworkUtil.getBundle(ServiceUtil.class);
- Conditions.checkNotNull(bundle, "bundle");
- BundleContext context = bundle.getBundleContext();
- Conditions.checkNotNull(context, "bundleContext");
- ServiceReference<T> reference = context.getServiceReference(clazz);
- Conditions.checkNotNull(reference, "serviceReference");
- T service = context.getService(reference);
- Conditions.checkNotNull(service, "service");
- return service;
+ return OsgiUtil.getService(ServiceUtil.class, clazz);
}
public static AccountClient getAccountClient() throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.orcs.db.mock/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.db.mock/META-INF/MANIFEST.MF
index 80859733d9..8a04cf14c1 100644
--- a/plugins/org.eclipse.osee.orcs.db.mock/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.db.mock/META-INF/MANIFEST.MF
@@ -6,6 +6,7 @@ Bundle-Version: 0.24.0.qualifier
Bundle-Vendor: Eclipse Open System Engineering Environment
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.eclipse.osee.framework.core.data,
+ 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.annotation,
diff --git a/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/OsgiUtil.java b/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/OsgiUtil.java
index 9bad66dcd2..c77c3135ab 100644
--- a/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/OsgiUtil.java
+++ b/plugins/org.eclipse.osee.orcs.db.mock/src/org/eclipse/osee/orcs/db/mock/internal/OsgiUtil.java
@@ -30,19 +30,7 @@ public final class OsgiUtil {
}
public static <T> T getService(Class<T> clazz) throws OseeCoreException {
- Bundle bundle = FrameworkUtil.getBundle(OsgiUtil.class);
- checkStarted(bundle);
-
- BundleContext context = bundle.getBundleContext();
- Assert.assertNotNull(context);
-
- ServiceReference<T> reference = context.getServiceReference(clazz);
- Assert.assertNotNull(String.format("Unable to find service [%s]", clazz), reference);
-
- T service = context.getService(reference);
- Assert.assertNotNull(String.format("Unable to find service instance for [%s]", clazz), service);
-
- return service;
+ return org.eclipse.osee.framework.core.util.OsgiUtil.getService(OsgiUtil.class, clazz);
}
public static <T> T getService(Class<T> clazz, String filter, long waitTimeMillis) throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.orcs.script.dsl.ui.integration/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.script.dsl.ui.integration/META-INF/MANIFEST.MF
index 9582499f51..3e1675e22c 100644
--- a/plugins/org.eclipse.osee.orcs.script.dsl.ui.integration/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.script.dsl.ui.integration/META-INF/MANIFEST.MF
@@ -12,6 +12,7 @@ Import-Package: org.eclipse.core.runtime,
org.eclipse.osee.framework.core.model,
org.eclipse.osee.framework.core.model.cache,
org.eclipse.osee.framework.core.services,
+ org.eclipse.osee.framework.core.util,
org.eclipse.osee.framework.jdk.core.type,
org.eclipse.osee.framework.skynet.core.types,
org.eclipse.osee.framework.ui.skynet,
diff --git a/plugins/org.eclipse.osee.orcs.script.dsl.ui.integration/src/org/eclipse/osee/orcs/script/dsl/ui/integration/internal/OrcsObjectProviderImpl.java b/plugins/org.eclipse.osee.orcs.script.dsl.ui.integration/src/org/eclipse/osee/orcs/script/dsl/ui/integration/internal/OrcsObjectProviderImpl.java
index 476c18980d..3b7f0583b4 100644
--- a/plugins/org.eclipse.osee.orcs.script.dsl.ui.integration/src/org/eclipse/osee/orcs/script/dsl/ui/integration/internal/OrcsObjectProviderImpl.java
+++ b/plugins/org.eclipse.osee.orcs.script.dsl.ui.integration/src/org/eclipse/osee/orcs/script/dsl/ui/integration/internal/OrcsObjectProviderImpl.java
@@ -12,13 +12,10 @@ package org.eclipse.osee.orcs.script.dsl.ui.integration.internal;
import java.util.Collections;
import org.eclipse.osee.framework.core.services.IOseeCachingService;
+import org.eclipse.osee.framework.core.util.OsgiUtil;
import org.eclipse.osee.framework.jdk.core.type.Identifiable;
import org.eclipse.osee.framework.jdk.core.type.NamedId;
import org.eclipse.osee.orcs.script.dsl.ui.IOrcsObjectProvider;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
/**
* @author Roberto E. Escobar
@@ -26,7 +23,7 @@ import org.osgi.framework.ServiceReference;
public class OrcsObjectProviderImpl implements IOrcsObjectProvider {
private IOseeCachingService getCache() {
- return getService(IOseeCachingService.class);
+ return OsgiUtil.getService(getClass(), IOseeCachingService.class);
}
@Override
@@ -52,20 +49,4 @@ public class OrcsObjectProviderImpl implements IOrcsObjectProvider {
IOseeCachingService caches = getCache();
return caches != null ? caches.getRelationTypeCache().getAll() : Collections.<Identifiable<Long>> emptyList();
}
-
- private <T> T getService(Class<T> clazz) {
- T service = null;
- Bundle bundle = FrameworkUtil.getBundle(getClass());
- if (bundle != null) {
- BundleContext context = bundle.getBundleContext();
- if (context != null) {
- ServiceReference<T> reference = context.getServiceReference(clazz);
- if (reference != null) {
- service = context.getService(reference);
- }
- }
- }
- return service;
- }
-
} \ No newline at end of file

Back to the top