Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blewitt2020-11-01 00:16:42 +0000
committerLeif Geiger2020-11-05 14:43:03 +0000
commit11719b74b46c03deff945ed17cdf1f4b339233dc (patch)
tree25e967f5c106f6a46f2386126e2e9c541b03b404
parent446fce51b7c658973273ec3712ee410afc39588a (diff)
downloadorg.eclipse.epp.mpc-11719b74b46c03deff945ed17cdf1f4b339233dc.tar.gz
org.eclipse.epp.mpc-11719b74b46c03deff945ed17cdf1f4b339233dc.tar.xz
org.eclipse.epp.mpc-11719b74b46c03deff945ed17cdf1f4b339233dc.zip
Bug 568414 - Remove Activator from MPC Core
The MPC.core plugin uses a Bundle-Activator which sets up some internal state, but most of this can be refactored away. This allows applications that depend on MPC to start faster. Refactor dependencies that are present in the MarketplaceClientCorePlugin so that the start/stop methods are no longer required. In addition, bump the require execution environment to Java 11, along with a minor service bump, since it depends on bundles that depend on Java 11. Change-Id: Idbb5d0205e3f2864db31fef61345779508cab68d Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
-rw-r--r--org.eclipse.epp.mpc.core/META-INF/MANIFEST.MF5
-rw-r--r--org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/MarketplaceClientCore.java3
-rw-r--r--org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/MarketplaceClientCorePlugin.java37
-rw-r--r--org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/util/TransportFactory.java8
-rw-r--r--org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/CatalogServiceTest.java4
-rw-r--r--org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/MappedTransportFactory.java4
-rw-r--r--org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/SolutionCompatibilityFilterTest.java12
-rw-r--r--org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/util/TransportFactoryTest.java3
8 files changed, 23 insertions, 53 deletions
diff --git a/org.eclipse.epp.mpc.core/META-INF/MANIFEST.MF b/org.eclipse.epp.mpc.core/META-INF/MANIFEST.MF
index 08c87dad..5a3984cd 100644
--- a/org.eclipse.epp.mpc.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.epp.mpc.core/META-INF/MANIFEST.MF
@@ -2,9 +2,9 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.epp.mpc.core;singleton:=true
-Bundle-Version: 1.8.5.qualifier
+Bundle-Version: 1.9.0.qualifier
Bundle-Vendor: %Bundle-Vendor
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.eclipse.osgi;bundle-version="3.6.0",
org.eclipse.core.runtime;bundle-version="3.6.0",
org.apache.commons.logging;bundle-version="1.0.4",
@@ -80,6 +80,5 @@ Import-Package: org.apache.http;version="4.4.0",
org.apache.http.util;version="4.4.0",
org.eclipse.equinox.p2.core;version="2.0.0"
Bundle-ActivationPolicy: lazy
-Bundle-Activator: org.eclipse.epp.internal.mpc.core.MarketplaceClientCorePlugin
Service-Component: OSGI-INF/services/*.xml
Automatic-Module-Name: org.eclipse.epp.mpc.core
diff --git a/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/MarketplaceClientCore.java b/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/MarketplaceClientCore.java
index 37333deb..895fbeca 100644
--- a/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/MarketplaceClientCore.java
+++ b/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/MarketplaceClientCore.java
@@ -30,6 +30,7 @@ import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
+import org.osgi.framework.FrameworkUtil;
/**
* @author David Green
@@ -45,7 +46,7 @@ public class MarketplaceClientCore {
private static final String PIPE_BROKEN_MESSAGE = "Pipe broken"; //$NON-NLS-1$
public static ILog getLog() {
- return Platform.getLog(MarketplaceClientCorePlugin.getBundle());
+ return Platform.getLog(FrameworkUtil.getBundle(MarketplaceClientCore.class));
}
public static void error(String message, Throwable exception) {
diff --git a/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/MarketplaceClientCorePlugin.java b/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/MarketplaceClientCorePlugin.java
index 5c7f2ccc..6f19c5b4 100644
--- a/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/MarketplaceClientCorePlugin.java
+++ b/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/MarketplaceClientCorePlugin.java
@@ -17,12 +17,9 @@ import org.eclipse.epp.internal.mpc.core.util.DebugTraceUtil;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.service.debug.DebugOptionsListener;
import org.eclipse.osgi.service.debug.DebugTrace;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
import org.osgi.service.component.annotations.Component;
-public class MarketplaceClientCorePlugin implements BundleActivator {
+public class MarketplaceClientCorePlugin {
public static final String DEBUG_OPTION = "/debug"; //$NON-NLS-1$
@@ -38,38 +35,6 @@ public class MarketplaceClientCorePlugin implements BundleActivator {
private static DebugTrace debugTrace;
- private static MarketplaceClientCorePlugin instance;
-
- private Bundle bundle;
-
- @Override
- public void start(BundleContext context) throws Exception {
- bundle = context.getBundle();
- instance = this;
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- debugTrace = null;
- instance = null;
- }
-
- /**
- * @deprecated Inject ServiceHelper as a service instead
- */
- @Deprecated
- public ServiceHelperImpl getServiceHelper() {
- return ServiceHelperImpl.getImplInstance();
- }
-
- public static MarketplaceClientCorePlugin getDefault() {
- return instance;
- }
-
- public static Bundle getBundle() {
- return instance == null ? null : instance.bundle;
- }
-
public static void trace(String option, String message) {
final DebugTrace trace = debugTrace;
if (DEBUG && trace != null) {
diff --git a/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/util/TransportFactory.java b/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/util/TransportFactory.java
index 3ebbae02..3806dd1e 100644
--- a/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/util/TransportFactory.java
+++ b/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/util/TransportFactory.java
@@ -34,6 +34,7 @@ import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.epp.internal.mpc.core.MarketplaceClientCore;
import org.eclipse.epp.internal.mpc.core.MarketplaceClientCorePlugin;
+import org.eclipse.epp.internal.mpc.core.ServiceHelperImpl;
import org.eclipse.epp.mpc.core.service.ITransportFactory;
import org.eclipse.epp.mpc.core.service.ServiceHelper;
import org.eclipse.epp.mpc.core.service.ServiceUnavailableException;
@@ -227,8 +228,7 @@ public abstract class TransportFactory implements ITransportFactory {
*/
@Deprecated
public static synchronized TransportFactory instance() {
- TransportFactory legacyTransportFactory = MarketplaceClientCorePlugin.getDefault()
- .getServiceHelper()
+ TransportFactory legacyTransportFactory = ServiceHelperImpl.getImplInstance()
.getLegacyTransportFactory();
if (legacyTransportFactory == null) {
throw new IllegalStateException();
@@ -238,7 +238,7 @@ public abstract class TransportFactory implements ITransportFactory {
public static org.eclipse.epp.mpc.core.service.ITransport createTransport() {
//search for registered factory service
- BundleContext context = MarketplaceClientCorePlugin.getBundle().getBundleContext();
+ BundleContext context = FrameworkUtil.getBundle(TransportFactory.class).getBundleContext();
Collection<ServiceReference<ITransportFactory>> serviceReferences = getTransportServiceReferences(context);
MultiStatus serviceError = null;
@@ -464,4 +464,4 @@ public abstract class TransportFactory implements ITransportFactory {
}
}
}
-} \ No newline at end of file
+}
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/CatalogServiceTest.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/CatalogServiceTest.java
index 95428bca..fcd83f11 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/CatalogServiceTest.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/CatalogServiceTest.java
@@ -21,7 +21,6 @@ import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.epp.internal.mpc.core.MarketplaceClientCorePlugin;
import org.eclipse.epp.internal.mpc.core.ServiceLocator;
import org.eclipse.epp.internal.mpc.core.model.Catalog;
import org.eclipse.epp.internal.mpc.core.service.CatalogService;
@@ -37,6 +36,7 @@ import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
@@ -64,7 +64,7 @@ public class CatalogServiceTest {
@Before
public void setUp() throws Exception {
- bundleContext = MarketplaceClientCorePlugin.getBundle().getBundleContext();
+ bundleContext = FrameworkUtil.getBundle(CatalogServiceTest.class).getBundleContext();
serviceLocatorReference = bundleContext.getServiceReference(IMarketplaceServiceLocator.class);
serviceLocator = bundleContext.getService(serviceLocatorReference);
catalogService = serviceLocator.getCatalogService();
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/MappedTransportFactory.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/MappedTransportFactory.java
index 18788e3b..6c2449e2 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/MappedTransportFactory.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/MappedTransportFactory.java
@@ -24,7 +24,6 @@ import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.epp.internal.mpc.core.MarketplaceClientCorePlugin;
import org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientTransport;
import org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientTransportFactory;
import org.eclipse.epp.internal.mpc.core.util.FallbackTransportFactory;
@@ -34,6 +33,7 @@ import org.eclipse.epp.mpc.core.service.ITransportFactory;
import org.eclipse.epp.mpc.core.service.ServiceHelper;
import org.eclipse.epp.mpc.core.service.ServiceUnavailableException;
import org.osgi.framework.Constants;
+import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceRegistration;
public class MappedTransportFactory implements ITransportFactory {
@@ -134,7 +134,7 @@ public class MappedTransportFactory implements ITransportFactory {
this.delegate = delegate;
Dictionary<String, Object> maxServiceRanking = new Hashtable<>(Collections.singletonMap(
Constants.SERVICE_RANKING, Integer.MAX_VALUE));
- registration = MarketplaceClientCorePlugin.getBundle().getBundleContext().registerService(
+ registration = FrameworkUtil.getBundle(MappedTransportFactory.class).getBundleContext().registerService(
ITransportFactory.class, this,
maxServiceRanking);
transportFactory = ServiceHelper.getTransportFactory();
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/SolutionCompatibilityFilterTest.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/SolutionCompatibilityFilterTest.java
index 9d3eeb95..65377594 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/SolutionCompatibilityFilterTest.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/SolutionCompatibilityFilterTest.java
@@ -12,8 +12,13 @@
*******************************************************************************/
package org.eclipse.epp.mpc.tests.service;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assume.*;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.isEmptyOrNullString;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assume.assumeFalse;
+import static org.junit.Assume.assumeTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -40,6 +45,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.epp.internal.mpc.core.MarketplaceClientCore;
import org.eclipse.epp.internal.mpc.core.MarketplaceClientCorePlugin;
+import org.eclipse.epp.internal.mpc.core.ServiceHelperImpl;
import org.eclipse.epp.internal.mpc.core.ServiceLocator;
import org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService;
import org.eclipse.epp.mpc.core.model.IIu;
@@ -577,7 +583,7 @@ public class SolutionCompatibilityFilterTest {
protected void starting(final Description description) {
final IMarketplaceUnmarshaller marketplaceUnmarshaller = org.eclipse.epp.mpc.core.service.ServiceHelper
.getMarketplaceUnmarshaller();
- unmarshallerRegistration = MarketplaceClientCorePlugin.getDefault().getServiceHelper()
+ unmarshallerRegistration = ServiceHelperImpl.getImplInstance()
.registerMarketplaceUnmarshaller(new IMarketplaceUnmarshaller() {
public <T> T unmarshal(InputStream in, Class<T> type, IProgressMonitor monitor)
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/util/TransportFactoryTest.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/util/TransportFactoryTest.java
index d0ce03a5..8e0bcd45 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/util/TransportFactoryTest.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/util/TransportFactoryTest.java
@@ -52,7 +52,6 @@ import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.epp.internal.mpc.core.MarketplaceClientCorePlugin;
import org.eclipse.epp.internal.mpc.core.ServiceHelperImpl;
import org.eclipse.epp.internal.mpc.core.transport.httpclient.ChainedCredentialsProvider;
import org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientCustomizer;
@@ -125,7 +124,7 @@ public class TransportFactoryTest {
@Test
public void testRegisteredFactories() throws Exception {
- BundleContext context = MarketplaceClientCorePlugin.getBundle().getBundleContext();
+ BundleContext context = FrameworkUtil.getBundle(TransportFactoryTest.class).getBundleContext();
Collection<ServiceReference<ITransportFactory>> serviceReferences = context.getServiceReferences(
ITransportFactory.class, null);
assertFalse(serviceReferences.isEmpty());

Back to the top