Bug 565303 - Use ServiceCaller for InternalPlatform.endSplash

Instead of looking up the service with a `ServiceReference` and an OSGi
filter, use the `ServiceCaller` from equinox.common to wrap the
get/call/unget service.

Change-Id: Ic1346d690abccb745766965140f5d4cd4dd0a00a
Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
index 77716ea..336685d 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
@@ -148,9 +148,9 @@
 				return; // do not do this more than once
 			splashEnded = true;
 		}
-		IApplicationContext applicationContext = getApplicationContext();
-		if (applicationContext != null)
-			applicationContext.applicationRunning();
+		final String filter = "(eclipse.application.type=main.thread)"; //$NON-NLS-1$
+		ServiceCaller.callOnce(InternalPlatform.class, IApplicationContext.class,
+				filter, IApplicationContext::applicationRunning);
 	}
 
 	/**
@@ -460,25 +460,6 @@
 		return runtimeInstance;
 	}
 
-	private IApplicationContext getApplicationContext() {
-		Collection<ServiceReference<IApplicationContext>> references;
-		try {
-			references = context.getServiceReferences(IApplicationContext.class, "(eclipse.application.type=main.thread)"); //$NON-NLS-1$
-		} catch (InvalidSyntaxException e) {
-			return null;
-		}
-		if (references == null || references.isEmpty())
-			return null;
-		// assumes the application context is available as a service
-		ServiceReference<IApplicationContext> firstRef = references.iterator().next();
-		IApplicationContext result = context.getService(firstRef);
-		if (result != null) {
-			context.ungetService(firstRef);
-			return result;
-		}
-		return null;
-	}
-
 	/**
 	 * XXX Investigate the usage of a service factory
 	 */