Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2008-04-18 10:04:49 +0000
committerTomasz Zarna2008-04-18 10:04:49 +0000
commit9efb8560d7af14471b9bc39988d96dfd5869e0d5 (patch)
treeae7d024acd86653f189406b54a27318adf7221a2 /bundles/org.eclipse.core.net
parent9bb7a1acbce64e85d18393c3249ce3c41275b32f (diff)
downloadeclipse.platform.team-9efb8560d7af14471b9bc39988d96dfd5869e0d5.tar.gz
eclipse.platform.team-9efb8560d7af14471b9bc39988d96dfd5869e0d5.tar.xz
eclipse.platform.team-9efb8560d7af14471b9bc39988d96dfd5869e0d5.zip
bug 214796: [Proxy] org.eclipse.core.net bundle should not require org.eclipse.core.runtime (core.runtime dependency removed)
Diffstat (limited to 'bundles/org.eclipse.core.net')
-rw-r--r--bundles/org.eclipse.core.net/META-INF/MANIFEST.MF7
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/Activator.java156
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java4
3 files changed, 114 insertions, 53 deletions
diff --git a/bundles/org.eclipse.core.net/META-INF/MANIFEST.MF b/bundles/org.eclipse.core.net/META-INF/MANIFEST.MF
index 09c5f4c94..5a0e5cba0 100644
--- a/bundles/org.eclipse.core.net/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.core.net/META-INF/MANIFEST.MF
@@ -6,8 +6,11 @@ Bundle-Version: 1.1.0.qualifier
Bundle-Activator: org.eclipse.core.internal.net.Activator
Bundle-Vendor: %PLUGIN_PROVIDER
Bundle-Localization: plugin
-Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)",
- org.eclipse.equinox.security;bundle-version="[1.0.0,2.0.0)"
+Require-Bundle: org.eclipse.equinox.security;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.equinox.common;bundle-version="3.4.0",
+ org.eclipse.equinox.preferences;bundle-version="3.2.200",
+ org.eclipse.osgi;bundle-version="3.4.0",
+ org.eclipse.equinox.registry;bundle-version="3.4.0"
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.core.internal.net;x-internal:=true,
org.eclipse.core.net.proxy
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/Activator.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/Activator.java
index 5d12b8bc0..7fcc97201 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/Activator.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/Activator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -15,37 +15,47 @@
package org.eclipse.core.internal.net;
+import java.util.ArrayList;
import java.util.Hashtable;
import org.eclipse.core.net.proxy.IProxyService;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.osgi.framework.log.FrameworkLog;
+import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.eclipse.osgi.service.datalocation.Location;
+import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceRegistration;
import org.osgi.util.tracker.ServiceTracker;
-public class Activator extends Plugin {
+public class Activator implements BundleActivator {
/**
* The identifier of the descriptor of this plugin in plugin.xml.
*/
public static final String ID = "org.eclipse.core.net"; //$NON-NLS-1$
-
- public static final String PT_AUTHENTICATOR = "authenticator"; //$NON-NLS-1$
-
- private static final String PROP_REGISTER_SERVICE = "org.eclipse.net.core.enableProxyService"; //$NON-NLS-1$
/**
* The instance of this plugin.
*/
private static Activator instance;
- private ServiceRegistration proxyService;
+ private static ServiceTracker logTracker;
+
+ private static final String PROP_REGISTER_SERVICE = "org.eclipse.net.core.enableProxyService"; //$NON-NLS-1$
+
+ public static final String PT_AUTHENTICATOR = "authenticator"; //$NON-NLS-1$
+
+ private BundleContext bundleContext;
private ServiceTracker instanceLocationTracker;
+ private ServiceRegistration proxyService;
+
/**
* Constructor for use by the Eclipse platform only.
*/
@@ -56,68 +66,116 @@ public class Activator extends Plugin {
/**
* Returns the instance of this plugin.
+ *
* @return the singleton instance of this plug-in class
*/
static public Activator getInstance() {
return instance;
}
+ public static void log(int severity, String message, Throwable throwable) {
+ getInstance().log(new Status(severity, ID, 0, message, throwable));
+ }
+
+ public static void logError(String message, Throwable exc) {
+ getInstance().log(new Status(IStatus.ERROR, ID, 0, message, exc));
+ }
+
+ public static void logInfo(String message, Throwable exc) {
+ getInstance().log(new Status(IStatus.INFO, ID, 0, message, exc));
+ }
+
+ /*
+ * Log the given status to the log file. If the log is not available, log
+ * the status to the console.
+ */
+ private void log(IStatus status) {
+ if (logTracker == null) {
+ logTracker = new ServiceTracker(bundleContext, FrameworkLog.class
+ .getName(), null);
+ logTracker.open();
+ }
+ FrameworkLog log = (FrameworkLog) logTracker.getService();
+ if (log != null) {
+ log.log(getLog(status));
+ } else {
+ System.out.println(status.getMessage());
+ if (status.getException() != null)
+ status.getException().printStackTrace();
+ }
+ }
+
+ /**
+ * Copied from PlatformLogWriter in core runtime.
+ */
+ private FrameworkLogEntry getLog(IStatus status) {
+ Throwable t = status.getException();
+ ArrayList childlist = new ArrayList();
+
+ int stackCode = t instanceof CoreException ? 1 : 0;
+ // ensure a substatus inside a CoreException is properly logged
+ if (stackCode == 1) {
+ IStatus coreStatus = ((CoreException) t).getStatus();
+ if (coreStatus != null) {
+ childlist.add(getLog(coreStatus));
+ }
+ }
+
+ if (status.isMultiStatus()) {
+ IStatus[] children = status.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ childlist.add(getLog(children[i]));
+ }
+ }
+
+ FrameworkLogEntry[] children = (FrameworkLogEntry[]) (childlist.size() == 0 ? null
+ : childlist.toArray(new FrameworkLogEntry[childlist.size()]));
+
+ return new FrameworkLogEntry(status.getPlugin(), status.getSeverity(),
+ status.getCode(), status.getMessage(), stackCode, t, children);
+ }
+
+ public org.osgi.service.prefs.Preferences getPreferences() {
+ return new ConfigurationScope().getNode(ID);
+ }
+
+ public boolean instanceLocationAvailable() {
+ Location instanceLocation = (Location) instanceLocationTracker
+ .getService();
+ return (instanceLocation != null && instanceLocation.isSet());
+ }
+
public void start(BundleContext context) throws Exception {
- super.start(context);
-
+ this.bundleContext = context;
Filter filter = null;
try {
- filter = context.createFilter(Location.INSTANCE_FILTER);
- } catch (InvalidSyntaxException e) {
- // ignore this. It should never happen as we have tested the above format.
- }
+ filter = context.createFilter(Location.INSTANCE_FILTER);
+ } catch (InvalidSyntaxException e) {
+ // ignore this. It should never happen as we have tested the above
+ // format.
+ }
instanceLocationTracker = new ServiceTracker(context, filter, null);
- instanceLocationTracker.open();
-
-
- if (Boolean.valueOf(System.getProperty(PROP_REGISTER_SERVICE, "true")).booleanValue()) { //$NON-NLS-1$
- ProxyManager proxyManager = (ProxyManager)ProxyManager.getProxyManager();
+ instanceLocationTracker.open();
+
+ if (Boolean
+ .valueOf(System.getProperty(PROP_REGISTER_SERVICE, "true")).booleanValue()) { //$NON-NLS-1$
+ ProxyManager proxyManager = (ProxyManager) ProxyManager
+ .getProxyManager();
proxyManager.initialize();
- proxyService = context.registerService(IProxyService.class.getName(), proxyManager, new Hashtable());
+ proxyService = context.registerService(IProxyService.class
+ .getName(), proxyManager, new Hashtable());
}
}
-
+
public void stop(BundleContext context) throws Exception {
if (proxyService != null) {
proxyService.unregister();
proxyService = null;
}
-
+
if (instanceLocationTracker != null) {
instanceLocationTracker.close();
instanceLocationTracker = null;
}
-
- super.stop(context);
- }
-
- public static void logError(String message, Throwable exc) {
- IStatus status = new Status(IStatus.ERROR, ID, 0, message, exc);
-
- getInstance().getLog().log(status);
- }
-
- public static void logInfo(String message, Throwable exc) {
- IStatus status = new Status(IStatus.INFO, ID, 0, message, exc);
-
- getInstance().getLog().log(status);
- }
-
- public org.osgi.service.prefs.Preferences getPreferences() {
- return new ConfigurationScope().getNode(getBundle().getSymbolicName());
- }
-
- public static void log(int severity, String message, Throwable throwable) {
- getInstance().getLog().log(new Status(severity, ID, 0, message, throwable));
- }
-
- public boolean instanceLocationAvailable() {
- Location instanceLocation = (Location) instanceLocationTracker.getService();
- return (instanceLocation != null && instanceLocation.isSet());
}
}
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java
index f0754be30..3bce3cd60 100644
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java
+++ b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/ProxyManager.java
@@ -28,7 +28,7 @@ import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
@@ -351,7 +351,7 @@ public class ProxyManager implements IProxyService, IPreferenceChangeListener {
}
private Authenticator getPluggedInAuthenticator() {
- IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(Activator.ID, Activator.PT_AUTHENTICATOR).getExtensions();
+ IExtension[] extensions = RegistryFactory.getRegistry().getExtensionPoint(Activator.ID, Activator.PT_AUTHENTICATOR).getExtensions();
if (extensions.length == 0)
return null;
IExtension extension = extensions[0];

Back to the top