Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Arthorne2008-04-11 14:06:26 -0400
committerJohn Arthorne2008-04-11 14:06:26 -0400
commit5446df3471c836dfad5c4f3faeea50bb18e1154a (patch)
tree4bdb6518dbdd75db4b762a49af4f674907aaf621 /bundles/org.eclipse.equinox.p2.directorywatcher
parentc223124b36206e6928cb501ebd339869f5490c51 (diff)
downloadrt.equinox.p2-5446df3471c836dfad5c4f3faeea50bb18e1154a.tar.gz
rt.equinox.p2-5446df3471c836dfad5c4f3faeea50bb18e1154a.tar.xz
rt.equinox.p2-5446df3471c836dfad5c4f3faeea50bb18e1154a.zip
Bug 226528 Excessive prompting for authenticated connections
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.directorywatcher')
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Activator.java42
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java31
3 files changed, 74 insertions, 1 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 b105ba6e0..cdf57eea2 100644
--- a/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/META-INF/MANIFEST.MF
@@ -9,6 +9,7 @@ Import-Package: org.eclipse.equinox.internal.p2.core.helpers,
org.eclipse.equinox.internal.p2.metadata.generator.features,
org.eclipse.equinox.internal.provisional.p2.artifact.repository,
org.eclipse.equinox.internal.provisional.p2.core,
+ org.eclipse.equinox.internal.provisional.p2.core.eventbus,
org.eclipse.equinox.internal.provisional.p2.core.repository,
org.eclipse.equinox.internal.provisional.p2.metadata,
org.eclipse.equinox.internal.provisional.p2.metadata.generator,
@@ -25,3 +26,4 @@ Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0,
J2SE-1.3
Export-Package: org.eclipse.equinox.internal.provisional.p2.directorywatcher;x-friends:="org.eclipse.equinox.p2.reconciler.dropins"
Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.3.0,4.0)"
+Bundle-Activator: org.eclipse.equinox.internal.provisional.p2.directorywatcher.Activator
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
new file mode 100644
index 000000000..b97dcd2f1
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/Activator.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.provisional.p2.directorywatcher;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * 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;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext aContext) throws Exception {
+ this.context = aContext;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext aContext) throws Exception {
+ this.context = null;
+ }
+
+}
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 5ab7e7659..c18433db9 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
@@ -13,11 +13,16 @@ import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
+import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.metadata.generator.features.FeatureParser;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository;
+import org.eclipse.equinox.internal.provisional.p2.core.repository.RepositoryEvent;
import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.metadata.generator.*;
@@ -82,6 +87,29 @@ public class RepositoryListener extends DirectoryChangeListener {
bundleDescriptionFactory = initializeBundleDescriptionFactory(context);
}
+ /**
+ * Broadcast events for any discovery sites associated with the feature
+ * so the repository managers add them to their list of known repositories.
+ */
+ private void broadcastDiscoverySites(Feature feature) {
+ URLEntry[] sites = feature.getDiscoverySites();
+ if (sites == null || sites.length == 0)
+ return;
+
+ IProvisioningEventBus bus = (IProvisioningEventBus) ServiceHelper.getService(Activator.getContext(), IProvisioningEventBus.SERVICE_NAME);
+ if (bus == null)
+ return;
+ for (int i = 0; i < sites.length; i++) {
+ try {
+ URL location = new URL(sites[i].getURL());
+ bus.publishEvent(new RepositoryEvent(location, IRepository.TYPE_METADATA, RepositoryEvent.DISCOVERED));
+ bus.publishEvent(new RepositoryEvent(location, IRepository.TYPE_ARTIFACT, RepositoryEvent.DISCOVERED));
+ } catch (MalformedURLException e) {
+ LogHelper.log(new Status(IStatus.WARNING, Activator.ID, "Feature has invalid discovery site: " + feature.getId(), e)); //$NON-NLS-1$
+ }
+ }
+ }
+
private BundleDescriptionFactory initializeBundleDescriptionFactory(BundleContext context) {
ServiceReference reference = context.getServiceReference(PlatformAdmin.class.getName());
@@ -381,9 +409,10 @@ public class RepositoryListener extends DirectoryChangeListener {
if (feature == null)
return null;
+ broadcastDiscoverySites(feature);
+
IInstallableUnit featureIU = MetadataGeneratorHelper.createFeatureJarIU(feature, true, props);
IInstallableUnit groupIU = MetadataGeneratorHelper.createGroupIU(feature, featureIU, props);
-
return new IInstallableUnit[] {featureIU, groupIU};
}

Back to the top