diff options
author | Lars Vogel | 2019-02-02 15:46:22 +0000 |
---|---|---|
committer | Lars Vogel | 2019-02-04 07:52:42 +0000 |
commit | 12953865426644202cd56f56c81cb9cd56951b3f (patch) | |
tree | 6dd08e78cc239b250cd3ee4ac11fa539d9b3fa5e /bundles | |
parent | bb787089473bc5cf473f0ed2e36513f97da65d74 (diff) | |
download | rt.equinox.p2-12953865426644202cd56f56c81cb9cd56951b3f.tar.gz rt.equinox.p2-12953865426644202cd56f56c81cb9cd56951b3f.tar.xz rt.equinox.p2-12953865426644202cd56f56c81cb9cd56951b3f.zip |
Bug 544065 - Remove Activator fromY20190208-0505Y20190206-2200Y20190205-0115I20190209-1800I20190208-1800I20190207-1800I20190206-1800I20190205-1800I20190204-1800
org.eclipse.equinox.p2.directorywatcher
Change-Id: I38c28303d56b0025f9bf6edbd76074ddce08824a
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
Diffstat (limited to 'bundles')
5 files changed, 54 insertions, 74 deletions
diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF index 47d316777..1a42883ad 100644 --- a/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF @@ -3,7 +3,6 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.equinox.p2.directorywatcher;singleton:=true Bundle-Version: 1.2.200.qualifier -Bundle-Activator: org.eclipse.equinox.internal.provisional.p2.directorywatcher.Activator Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.equinox.internal.provisional.p2.directorywatcher;x-friends:="org.eclipse.equinox.p2.reconciler.dropins,org.eclipse.equinox.p2.extensionlocation" diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Activator.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Activator.java deleted file mode 100644 index a34fb4530..000000000 --- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Activator.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2017 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Code 9 - ongoing development - * Red Hat Inc. - Bug 460967 - *******************************************************************************/ -package org.eclipse.equinox.internal.provisional.p2.directorywatcher; - -import java.io.File; -import java.net.URI; -import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; -import org.eclipse.equinox.p2.core.IProvisioningAgent; -import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; -import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; -import org.osgi.framework.*; - -/** - * Bundle activator for directory watcher bundle. - */ -public class Activator implements BundleActivator { - public static final String ID = "org.eclipse.equinox.p2.directorywatcher"; //$NON-NLS-1$ - - private static BundleContext context; - - public static BundleContext getContext() { - return context; - } - - @Override - public void start(BundleContext aContext) throws Exception { - context = aContext; - } - - @Override - public void stop(BundleContext aContext) throws Exception { - context = null; - } - - public static IArtifactRepositoryManager getArtifactRepositoryManager() { - return ServiceHelper.getService(context, IProvisioningAgent.class).getService(IArtifactRepositoryManager.class); - } - - public static IMetadataRepositoryManager getMetadataRepositoryManager() { - return ServiceHelper.getService(context, IProvisioningAgent.class).getService(IMetadataRepositoryManager.class); - } - - public static URI getDefaultRepositoryLocation(Object object, String repositoryName) { - Bundle bundle = FrameworkUtil.getBundle(object.getClass()); - BundleContext context = bundle.getBundleContext(); - File base = context.getDataFile(""); //$NON-NLS-1$ - File result = new File(base, "listener_" + repositoryName.hashCode()); //$NON-NLS-1$ - result.mkdirs(); - return result.toURI(); - } -} diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository.java index 9fdd03a9d..104bb1ec1 100644 --- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository.java +++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository.java @@ -412,9 +412,9 @@ public class CachingArtifactRepository implements IFileArtifactRepository { try { runnable.run(monitor); } catch (OperationCanceledException oce) { - return new Status(IStatus.CANCEL, Activator.ID, oce.getMessage(), oce); + return new Status(IStatus.CANCEL, Constants.BUNDLE_ID, oce.getMessage(), oce); } catch (Exception e) { - return new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e); + return new Status(IStatus.ERROR, Constants.BUNDLE_ID, e.getMessage(), e); } return Status.OK_STATUS; } diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Constants.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Constants.java new file mode 100644 index 000000000..a1b13e356 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Constants.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2008, 2017 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + * Code 9 - ongoing development + * Red Hat Inc. - Bug 460967 + *******************************************************************************/ +package org.eclipse.equinox.internal.provisional.p2.directorywatcher; + +/** + * Constants interface for the bundle ID + */ +public interface Constants { + public static final String BUNDLE_ID = "org.eclipse.equinox.p2.directorywatcher"; //$NON-NLS-1$ + +} diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java index 0880cef8b..3b9998200 100644 --- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java +++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java @@ -19,9 +19,9 @@ import java.net.URI; import java.util.*; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor; -import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; -import org.eclipse.equinox.internal.p2.core.helpers.Tracing; +import org.eclipse.equinox.internal.p2.core.helpers.*; import org.eclipse.equinox.internal.p2.update.Site; +import org.eclipse.equinox.p2.core.IProvisioningAgent; import org.eclipse.equinox.p2.core.ProvisionException; import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.*; @@ -33,6 +33,7 @@ import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.osgi.service.resolver.BundleDescription; import org.eclipse.osgi.util.NLS; +import org.osgi.framework.*; public class RepositoryListener extends DirectoryChangeListener { public static final String ARTIFACT_FOLDER = "artifact.folder"; //$NON-NLS-1$ @@ -58,7 +59,7 @@ public class RepositoryListener extends DirectoryChangeListener { * @param properties the map of repository properties or <code>null</code> */ public RepositoryListener(String repositoryName, Map<String, String> properties) { - URI location = Activator.getDefaultRepositoryLocation(this, repositoryName); + URI location = getDefaultRepositoryLocation(this, repositoryName); metadataRepository = initializeMetadataRepository(repositoryName, location, properties); artifactRepository = initializeArtifactRepository(repositoryName, location, properties); initializePublisher(); @@ -79,7 +80,7 @@ public class RepositoryListener extends DirectoryChangeListener { } protected CachingArtifactRepository initializeArtifactRepository(String name, URI repositoryLocation, Map<String, String> properties) { - IArtifactRepositoryManager manager = Activator.getArtifactRepositoryManager(); + IArtifactRepositoryManager manager = getArtifactRepositoryManager(); if (manager == null) throw new IllegalStateException(Messages.artifact_repo_manager_not_registered); @@ -99,7 +100,7 @@ public class RepositoryListener extends DirectoryChangeListener { } protected IMetadataRepository initializeMetadataRepository(String name, URI repositoryLocation, Map<String, String> properties) { - IMetadataRepositoryManager manager = Activator.getMetadataRepositoryManager(); + IMetadataRepositoryManager manager = getMetadataRepositoryManager(); if (manager == null) throw new IllegalStateException(Messages.metadata_repo_manager_not_registered); @@ -244,7 +245,7 @@ public class RepositoryListener extends DirectoryChangeListener { if (filename == null) { if (Tracing.DEBUG) { String message = NLS.bind(Messages.filename_missing, "artifact", descriptor.getArtifactKey()); //$NON-NLS-1$ - LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message, null)); + LogHelper.log(new Status(IStatus.ERROR, Constants.BUNDLE_ID, message, null)); } } else { File artifactFile = new File(filename); @@ -270,7 +271,7 @@ public class RepositoryListener extends DirectoryChangeListener { if (filename == null) { if (Tracing.DEBUG) { String message = NLS.bind(Messages.filename_missing, "installable unit", iu.getId()); //$NON-NLS-1$ - LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message, null)); + LogHelper.log(new Status(IStatus.ERROR, Constants.BUNDLE_ID, message, null)); } } else { File iuFile = new File(filename); @@ -304,4 +305,24 @@ public class RepositoryListener extends DirectoryChangeListener { public IArtifactRepository getArtifactRepository() { return artifactRepository; } + + private static IMetadataRepositoryManager getMetadataRepositoryManager() { + BundleContext bundleContext = FrameworkUtil.getBundle(RepositoryListener.class).getBundleContext(); + return ServiceHelper.getService(bundleContext, IProvisioningAgent.class).getService(IMetadataRepositoryManager.class); + } + + private static IArtifactRepositoryManager getArtifactRepositoryManager() { + BundleContext bundleContext = FrameworkUtil.getBundle(RepositoryListener.class).getBundleContext(); + return ServiceHelper.getService(bundleContext, IProvisioningAgent.class).getService(IArtifactRepositoryManager.class); + } + + private static URI getDefaultRepositoryLocation(Object object, String repositoryName) { + Bundle bundle = FrameworkUtil.getBundle(object.getClass()); + BundleContext context = bundle.getBundleContext(); + File base = context.getDataFile(""); //$NON-NLS-1$ + File result = new File(base, "listener_" + repositoryName.hashCode()); //$NON-NLS-1$ + result.mkdirs(); + return result.toURI(); + } + } |