From 218a01ab0bfac3027df1e212412a0f3445c363a1 Mon Sep 17 00:00:00 2001 From: Alex Blewitt Date: Mon, 2 Nov 2020 21:25:11 +0000 Subject: [PATCH] Bug 568414 - Finish off removing Activator from core Having removed the main content from the Activator/Plugin, we can now refactor and remove the class completely from the plugin. Change-Id: Iede1ee2e1ad62f256af8665b47a5a5fb4830590e Signed-off-by: Alex Blewitt --- ...org.eclipse.epp.mpc.core.debug.options.xml | 14 ++-- .../mpc/core/MarketplaceClientCorePlugin.java | 72 ------------------- .../epp/internal/mpc/core/ServiceLocator.java | 37 ++++++++-- .../mpc/core/util/TransportFactory.java | 1 - .../SolutionCompatibilityFilterTest.java | 1 - 5 files changed, 40 insertions(+), 85 deletions(-) delete mode 100644 org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/MarketplaceClientCorePlugin.java diff --git a/org.eclipse.epp.mpc.core/OSGI-INF/services/org.eclipse.epp.mpc.core.debug.options.xml b/org.eclipse.epp.mpc.core/OSGI-INF/services/org.eclipse.epp.mpc.core.debug.options.xml index f4fc55d5..f9e69934 100644 --- a/org.eclipse.epp.mpc.core/OSGI-INF/services/org.eclipse.epp.mpc.core.debug.options.xml +++ b/org.eclipse.epp.mpc.core/OSGI-INF/services/org.eclipse.epp.mpc.core.debug.options.xml @@ -1,8 +1,8 @@ - - - - - - - + + + + + + + \ No newline at end of file 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 deleted file mode 100644 index 6f19c5b4..00000000 --- a/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/MarketplaceClientCorePlugin.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2018 The Eclipse Foundation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Yatta Solutions - initial API and implementation - * Yatta Solutions - bug 432803: public API - *******************************************************************************/ -package org.eclipse.epp.internal.mpc.core; - -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.service.component.annotations.Component; - -public class MarketplaceClientCorePlugin { - - public static final String DEBUG_OPTION = "/debug"; //$NON-NLS-1$ - - public static final String DEBUG_FAKE_CLIENT_OPTION = "/client/fakeVersion"; //$NON-NLS-1$ - - public static final String DEBUG_CLIENT_OPTIONS_PATH = MarketplaceClientCore.BUNDLE_ID + "/client/"; //$NON-NLS-1$ - - public static final String DEBUG_CLIENT_REMOVE_OPTION = "xxx"; //$NON-NLS-1$ - - public static boolean DEBUG = false; - - public static boolean DEBUG_FAKE_CLIENT = false; - - private static DebugTrace debugTrace; - - public static void trace(String option, String message) { - final DebugTrace trace = debugTrace; - if (DEBUG && trace != null) { - trace.trace(option, message); - } - } - - public static void trace(String option, String message, Object... parameters) { - final DebugTrace trace = debugTrace; - if (DEBUG && trace != null) { - DebugTraceUtil.trace(trace, option, message, parameters); - } - } - - @Component(name = "org.eclipse.epp.mpc.core.debug.options", property = { - "listener.symbolic.name=org.eclipse.epp.mpc.core" }) - public static class DebugOptionsInitializer implements DebugOptionsListener { - - @Override - public void optionsChanged(DebugOptions options) { - DebugTrace debugTrace = null; - boolean debug = options.getBooleanOption(MarketplaceClientCore.BUNDLE_ID + DEBUG_OPTION, false); - boolean fakeClient = false; - if (debug) { - debugTrace = options.newDebugTrace(MarketplaceClientCore.BUNDLE_ID); - fakeClient = options.getBooleanOption(MarketplaceClientCore.BUNDLE_ID + DEBUG_FAKE_CLIENT_OPTION, - false); - } - DEBUG = debug; - DEBUG_FAKE_CLIENT = fakeClient; - MarketplaceClientCorePlugin.debugTrace = debugTrace; - } - - } -} diff --git a/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/ServiceLocator.java b/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/ServiceLocator.java index 5347fe38..aec332b4 100644 --- a/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/ServiceLocator.java +++ b/org.eclipse.epp.mpc.core/src/org/eclipse/epp/internal/mpc/core/ServiceLocator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2018 The Eclipse Foundation and others. + * Copyright (c) 2010, 2020 The Eclipse Foundation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -38,6 +38,8 @@ import org.eclipse.epp.mpc.core.service.IMarketplaceStorageService; import org.eclipse.epp.mpc.core.service.IUserFavoritesService; import org.eclipse.epp.mpc.core.service.ServiceHelper; +import org.eclipse.osgi.service.debug.DebugOptions; +import org.eclipse.osgi.service.debug.DebugOptionsListener; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; @@ -59,8 +61,35 @@ @Component(name = "org.eclipse.epp.mpc.core.servicelocator", service = IMarketplaceServiceLocator.class) public class ServiceLocator implements IMarketplaceServiceLocator { + private static final String DEBUG_CLIENT_REMOVE_OPTION = "xxx"; //$NON-NLS-1$ + private static final String STORAGE_SERVICE_BINDING_ID = "bind.storageService"; //$NON-NLS-1$ + private static final String DEBUG_CLIENT_OPTIONS_PATH = MarketplaceClientCore.BUNDLE_ID + "/client/"; //$NON-NLS-1$ + + private static boolean DEBUG_FAKE_CLIENT = false; + + private static final String DEBUG_OPTION = "/debug"; //$NON-NLS-1$ + + private static final String DEBUG_FAKE_CLIENT_OPTION = "/client/fakeVersion"; //$NON-NLS-1$ + + @Component(name = "org.eclipse.epp.mpc.core.debug.options", property = { + "listener.symbolic.name=org.eclipse.epp.mpc.core" }) + public static class DebugOptionsInitializer implements DebugOptionsListener { + + @Override + public void optionsChanged(DebugOptions options) { + boolean debug = options.getBooleanOption(MarketplaceClientCore.BUNDLE_ID + DEBUG_OPTION, false); + boolean fakeClient = false; + if (debug) { + fakeClient = options.getBooleanOption(MarketplaceClientCore.BUNDLE_ID + DEBUG_FAKE_CLIENT_OPTION, + false); + } + DEBUG_FAKE_CLIENT = fakeClient; + } + + } + private abstract class DynamicBindingOperation implements ServiceReferenceOperation { private final String dynamicBindId; @@ -675,9 +704,9 @@ public static Map computeProductInfo() { private static void addDefaultRequestMetaParameter(Map requestMetaParameters, String key, String value) { - if (MarketplaceClientCorePlugin.DEBUG_FAKE_CLIENT) { - String debugOption = Platform.getDebugOption(MarketplaceClientCorePlugin.DEBUG_CLIENT_OPTIONS_PATH + key); - if (MarketplaceClientCorePlugin.DEBUG_CLIENT_REMOVE_OPTION.equals(debugOption)) { + if (DEBUG_FAKE_CLIENT) { + String debugOption = Platform.getDebugOption(DEBUG_CLIENT_OPTIONS_PATH + key); + if (DEBUG_CLIENT_REMOVE_OPTION.equals(debugOption)) { requestMetaParameters.remove(key); return; } else if (debugOption != null && !"".equals(debugOption)) { //$NON-NLS-1$ 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 3806dd1e..5314c552 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 @@ -33,7 +33,6 @@ 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; 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 65377594..1a72a683 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 @@ -44,7 +44,6 @@ 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;