Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 207802 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/equinox/p2/artifact/repository/IArtifactRepositoryWithRangeSupport.java (+25 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 Genuitec, LLC and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Genuitec, LLC - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.equinox.p2.artifact.repository;
12
13
import java.io.OutputStream;
14
import org.eclipse.core.runtime.IProgressMonitor;
15
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.ecf.filetransfer.IFileRangeSpecification;
17
18
public interface IArtifactRepositoryWithRangeSupport extends IArtifactRepository {
19
20
	/**
21
	 * Return a stream containing the described artifact, or null if not available 
22
	 */
23
	public IStatus getArtifact(IArtifactDescriptor descriptor, IFileRangeSpecification range, OutputStream destination, IProgressMonitor monitor);
24
25
}
(-).settings/org.eclipse.pde.core.prefs (-2 / +3 lines)
Lines 1-4 Link Here
1
1
#Mon Oct 29 09:10:03 EDT 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
pluginProject.extensions=false
3
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
4
pluginProject.extensions=true
4
resolve.requirebundle=false
5
resolve.requirebundle=false
(-)build.properties (-1 / +3 lines)
Lines 12-16 Link Here
12
output.. = bin/
12
output.. = bin/
13
bin.includes = META-INF/,\
13
bin.includes = META-INF/,\
14
               .,\
14
               .,\
15
               about.html
15
               about.html,\
16
               plugin.xml,\
17
               schema/
16
src.includes = about.html
18
src.includes = about.html
(-)src/org/eclipse/equinox/internal/p2/download/DownloadActivator.java (-4 / +10 lines)
Lines 10-30 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.equinox.internal.p2.download;
11
package org.eclipse.equinox.internal.p2.download;
12
12
13
import org.osgi.framework.BundleActivator;
13
import org.eclipse.equinox.internal.p2.download.strategy.DownloadStrategyManager;
14
import org.osgi.framework.BundleContext;
14
import org.eclipse.equinox.p2.download.strategy.IDownloadStrategyManager;
15
import org.osgi.framework.*;
15
16
16
public class DownloadActivator implements BundleActivator {
17
public class DownloadActivator implements BundleActivator {
17
	public static final String ID = "org.eclipse.equinox.p2.download";
18
	public static final String ID = "org.eclipse.equinox.p2.download";
18
19
19
	public static BundleContext context;
20
	public static BundleContext context;
20
21
22
	private ServiceRegistration strategyManagerRegistration;
23
21
	public void start(BundleContext context) throws Exception {
24
	public void start(BundleContext context) throws Exception {
22
		DownloadActivator.context = context;
25
		DownloadActivator.context = context;
23
26
		DownloadStrategyManager strategyManager = new DownloadStrategyManager();
27
		strategyManagerRegistration = context.registerService(IDownloadStrategyManager.class.getName(), strategyManager, null);
24
	}
28
	}
25
29
26
	public void stop(BundleContext context) throws Exception {
30
	public void stop(BundleContext context) throws Exception {
27
		DownloadActivator.context = null;
31
		DownloadActivator.context = null;
32
		if (strategyManagerRegistration != null)
33
			strategyManagerRegistration.unregister();
34
		strategyManagerRegistration = null;
28
	}
35
	}
29
30
}
36
}
(-)src/org/eclipse/equinox/p2/download/DownloadManager.java (-6 / +69 lines)
Lines 10-22 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.equinox.p2.download;
11
package org.eclipse.equinox.p2.download;
12
12
13
import java.util.ArrayList;
13
import java.util.*;
14
import java.util.Iterator;
15
import org.eclipse.core.runtime.*;
14
import org.eclipse.core.runtime.*;
16
import org.eclipse.equinox.internal.p2.download.DownloadActivator;
15
import org.eclipse.equinox.internal.p2.download.DownloadActivator;
17
import org.eclipse.equinox.p2.artifact.repository.*;
16
import org.eclipse.equinox.p2.artifact.repository.*;
18
import org.eclipse.equinox.p2.core.helpers.MultiStatus;
17
import org.eclipse.equinox.p2.core.helpers.MultiStatus;
19
import org.eclipse.equinox.p2.core.helpers.ServiceHelper;
18
import org.eclipse.equinox.p2.core.helpers.ServiceHelper;
19
import org.eclipse.equinox.p2.download.strategy.*;
20
20
21
public class DownloadManager {
21
public class DownloadManager {
22
	ArrayList requestsToProcess = new ArrayList();
22
	ArrayList requestsToProcess = new ArrayList();
Lines 52-64 Link Here
52
		try {
52
		try {
53
			if (requestsToProcess.isEmpty())
53
			if (requestsToProcess.isEmpty())
54
				return Status.OK_STATUS;
54
				return Status.OK_STATUS;
55
56
			IDownloadStrategyManager strategyMgr = (IDownloadStrategyManager) ServiceHelper.getService(DownloadActivator.context, IDownloadStrategyManager.class.getName());
57
			IDownloadStrategy[] strategies = strategyMgr.getKnownStrategies();
58
			if (strategies.length == 0)
59
				return new Status(IStatus.ERROR, DownloadActivator.ID, "No strategy available");
60
55
			IArtifactRepositoryManager repoMgr = (IArtifactRepositoryManager) ServiceHelper.getService(DownloadActivator.context, IArtifactRepositoryManager.class.getName());
61
			IArtifactRepositoryManager repoMgr = (IArtifactRepositoryManager) ServiceHelper.getService(DownloadActivator.context, IArtifactRepositoryManager.class.getName());
56
			IArtifactRepository[] repositories = repoMgr.getKnownRepositories();
62
			IArtifactRepository[] repositories = repoMgr.getKnownRepositories();
57
			if (repositories.length == 0)
63
			if (repositories.length == 0)
58
				return new Status(IStatus.ERROR, DownloadActivator.ID, "No repository available");
64
				return new Status(IStatus.ERROR, DownloadActivator.ID, "No repository available");
59
			for (int i = 0; i < repositories.length && !requestsToProcess.isEmpty() && !monitor.isCanceled(); i++) {
65
60
				IArtifactRequest[] requests = getRequestsForRepository(repositories[i]);
66
			// determine which strategies will work best for these repositories
61
				IStatus dlStatus = repositories[i].getArtifacts(requests, subMonitor.newChild(requests.length));
67
			StrategyRequests[] strategyRequests = determineStrategies(monitor, strategies, repositories);
68
69
			// delegate work to the various strategies
70
			for (int i = 0; i < strategyRequests.length && !requestsToProcess.isEmpty() && !monitor.isCanceled(); i++) {
71
				IStatus dlStatus = strategyRequests[i].process(subMonitor);
62
				if (dlStatus.getSeverity() == IStatus.CANCEL)
72
				if (dlStatus.getSeverity() == IStatus.CANCEL)
63
					return overallStatus(monitor);
73
					return overallStatus(monitor);
64
				filterUnfetched();
74
				filterUnfetched();
Lines 71-76 Link Here
71
		}
81
		}
72
	}
82
	}
73
83
84
	private StrategyRequests[] determineStrategies(IProgressMonitor monitor, IDownloadStrategy[] strategies, IArtifactRepository[] repositories) {
85
		StrategyRequests[] strategyRequests = new StrategyRequests[strategies.length];
86
		for (int i = 0; i < repositories.length && !monitor.isCanceled(); i++) {
87
			IArtifactRequest[] requests = getRequestsForRepository(repositories[i]);
88
			if (requests.length == 0)
89
				continue;
90
91
			IDownloadStrategy bestStrategy = null;
92
			int strategyIdx = -1;
93
			for (int j = 0; j < strategies.length; j++) {
94
				if (!strategies[j].supportsRepository(repositories[i]))
95
					break;
96
				if (bestStrategy == null || strategies[j].isBetterThan(bestStrategy, repositories[i])) {
97
					bestStrategy = strategies[j];
98
					strategyIdx = j;
99
				}
100
			}
101
			if (bestStrategy == null)
102
				continue;
103
104
			if (strategyRequests[strategyIdx] == null)
105
				strategyRequests[strategyIdx] = new StrategyRequests(strategies[strategyIdx]);
106
			strategyRequests[strategyIdx].queueWork(repositories[i], requests);
107
		}
108
109
		List toUse = new ArrayList(strategyRequests.length);
110
		for (int i = 0; i < strategyRequests.length; i++)
111
			if (strategyRequests[i] != null)
112
				toUse.add(strategyRequests[i]);
113
		return (StrategyRequests[]) toUse.toArray(new StrategyRequests[toUse.size()]);
114
	}
115
74
	private IArtifactRequest[] getRequestsForRepository(IArtifactRepository repository) {
116
	private IArtifactRequest[] getRequestsForRepository(IArtifactRepository repository) {
75
		ArrayList applicable = new ArrayList();
117
		ArrayList applicable = new ArrayList();
76
		for (Iterator it = requestsToProcess.iterator(); it.hasNext();) {
118
		for (Iterator it = requestsToProcess.iterator(); it.hasNext();) {
Lines 102-105 Link Here
102
		}
144
		}
103
		return result;
145
		return result;
104
	}
146
	}
105
}
147
148
	private static final class StrategyRequests {
149
150
		private final IDownloadStrategy strategy;
151
		private final List strategyRequests = new ArrayList();
152
		private final Set totalRequests = new HashSet();
153
154
		StrategyRequests(IDownloadStrategy strategy) {
155
			this.strategy = strategy;
156
		}
157
158
		void queueWork(IArtifactRepository artifactRepository, IArtifactRequest[] requests) {
159
			totalRequests.addAll(Arrays.asList(requests));
160
			strategyRequests.add(new DownloadStrategyRequests(artifactRepository, requests));
161
		}
162
163
		IStatus process(SubMonitor subMonitor) {
164
			DownloadStrategyRequests requests[] = (DownloadStrategyRequests[]) strategyRequests.toArray(new DownloadStrategyRequests[strategyRequests.size()]);
165
			return strategy.getArtifacts(requests, subMonitor.newChild(totalRequests.size()));
166
		}
167
	}
168
}
(-)META-INF/MANIFEST.MF (-3 / +5 lines)
Lines 1-14 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-SymbolicName: org.eclipse.equinox.p2.download
3
Bundle-SymbolicName: org.eclipse.equinox.p2.download;singleton:=true
4
Bundle-Name: %pluginName
4
Bundle-Name: %pluginName
5
Bundle-Vendor: %providerName
5
Bundle-Vendor: %providerName
6
Bundle-Localization: plugin
6
Bundle-Localization: plugin
7
Bundle-Version: 0.1.0.qualifier
7
Bundle-Version: 0.1.0.qualifier
8
Export-Package: org.eclipse.equinox.internal.p2.download;x-internal:=true,
8
Export-Package: org.eclipse.equinox.internal.p2.download;x-internal:=true,
9
 org.eclipse.equinox.p2.download
9
 org.eclipse.equinox.p2.download,
10
 org.eclipse.equinox.p2.download.strategy
10
Require-Bundle: org.eclipse.equinox.common
11
Require-Bundle: org.eclipse.equinox.common
11
Import-Package: org.eclipse.equinox.internal.p2.core,
12
Import-Package: org.eclipse.core.runtime,
13
 org.eclipse.equinox.internal.p2.core,
12
 org.eclipse.equinox.p2.artifact.repository,
14
 org.eclipse.equinox.p2.artifact.repository,
13
 org.eclipse.equinox.p2.core.eventbus,
15
 org.eclipse.equinox.p2.core.eventbus,
14
 org.eclipse.equinox.p2.core.helpers,
16
 org.eclipse.equinox.p2.core.helpers,
(-)src/org/eclipse/equinox/p2/download/strategy/IDownloadStrategy.java (+28 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 Genuitec, LLC and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Genuitec, LLC - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.equinox.p2.download.strategy;
12
13
import org.eclipse.core.runtime.IProgressMonitor;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
16
17
/**
18
 * Provides a strategy that understands how to perform downloading from one or more
19
 * repositories.
20
 */
21
public interface IDownloadStrategy {
22
23
	boolean supportsRepository(IArtifactRepository artifactRepository);
24
25
	boolean isBetterThan(IDownloadStrategy other, IArtifactRepository artifactRepository);
26
27
	IStatus getArtifacts(DownloadStrategyRequests[] requests, IProgressMonitor monitor);
28
}
(-)src/org/eclipse/equinox/p2/download/strategy/DownloadStrategyRequests.java (+33 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 Genuitec, LLC and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Genuitec, LLC - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.equinox.p2.download.strategy;
12
13
import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
14
import org.eclipse.equinox.p2.artifact.repository.IArtifactRequest;
15
16
public class DownloadStrategyRequests {
17
18
	private final IArtifactRepository artifactRepository;
19
	private final IArtifactRequest[] requests;
20
21
	public DownloadStrategyRequests(IArtifactRepository artifactRepository, IArtifactRequest[] requests) {
22
		this.artifactRepository = artifactRepository;
23
		this.requests = requests;
24
	}
25
26
	public IArtifactRepository getRepository() {
27
		return artifactRepository;
28
	}
29
30
	public IArtifactRequest[] getRequests() {
31
		return requests;
32
	}
33
}
(-)plugin.xml (+12 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.2"?>
3
<plugin>
4
   <extension-point id="downloadStrategies" name="Download Strategies" schema="schema/downloadStrategies.exsd"/>
5
   <extension
6
         point="org.eclipse.equinox.p2.download.downloadStrategies">
7
      <strategy
8
            class="org.eclipse.equinox.internal.p2.download.strategy.SimpleDownloadStrategy">
9
      </strategy>
10
   </extension>
11
12
</plugin>
(-)src/org/eclipse/equinox/internal/p2/download/strategy/SimpleDownloadStrategy.java (+77 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 Genuitec, LLC and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Genuitec, LLC - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.equinox.internal.p2.download.strategy;
12
13
import java.util.*;
14
import org.eclipse.equinox.p2.core.helpers.MultiStatus;
15
import org.eclipse.core.runtime.*;
16
import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
17
import org.eclipse.equinox.p2.artifact.repository.IArtifactRequest;
18
import org.eclipse.equinox.p2.download.strategy.DownloadStrategyRequests;
19
import org.eclipse.equinox.p2.download.strategy.IDownloadStrategy;
20
21
/**
22
 * The simplest download strategy that can work with all repository formats
23
 * and is better than no other repository -- single threaded, sequential through
24
 * the various artifacts until all requests are processed. 
25
 */
26
public class SimpleDownloadStrategy implements IDownloadStrategy {
27
28
	public IStatus getArtifacts(DownloadStrategyRequests[] requests, IProgressMonitor monitor) {
29
30
		Set requestsToProcess = new HashSet();
31
		for (int i = 0; i < requests.length; i++)
32
			requestsToProcess.addAll(Arrays.asList(requests[i].getRequests()));
33
		SubMonitor subMonitor = SubMonitor.convert(monitor, "Downloading artifacts", requestsToProcess.size());
34
35
		for (int i = 0; i < requests.length && !requestsToProcess.isEmpty() && !monitor.isCanceled(); i++) {
36
			IStatus dlStatus = requests[i].getRepository().getArtifacts(requests[i].getRequests(), subMonitor.newChild(requests[i].getRequests().length));
37
			if (dlStatus.getSeverity() == IStatus.CANCEL)
38
				return overallStatus(requestsToProcess, monitor);
39
			filterUnfetched(requestsToProcess);
40
			subMonitor.setWorkRemaining(requestsToProcess.size());
41
		}
42
43
		return overallStatus(requestsToProcess, monitor);
44
	}
45
46
	public boolean isBetterThan(IDownloadStrategy other, IArtifactRepository artifactRepository) {
47
		return false;
48
	}
49
50
	public boolean supportsRepository(IArtifactRepository artifactRepository) {
51
		return true;
52
	}
53
54
	private void filterUnfetched(Set requestsToProcess) {
55
		for (Iterator iterator = requestsToProcess.iterator(); iterator.hasNext();) {
56
			IArtifactRequest request = (IArtifactRequest) iterator.next();
57
			if (request.getResult() != null && request.getResult().isOK()) {
58
				iterator.remove();
59
			}
60
		}
61
	}
62
63
	private IStatus overallStatus(Set requestsToProcess, IProgressMonitor monitor) {
64
		if (monitor.isCanceled())
65
			return Status.CANCEL_STATUS;
66
67
		if (requestsToProcess.size() == 0)
68
			return Status.OK_STATUS;
69
70
		MultiStatus result = new MultiStatus();
71
		for (Iterator iterator = requestsToProcess.iterator(); iterator.hasNext();) {
72
			IArtifactRequest failed = (IArtifactRequest) iterator.next();
73
			result.add(failed.getResult());
74
		}
75
		return result;
76
	}
77
}
(-)schema/downloadStrategies.exsd (+105 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.equinox.p2.download">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.equinox.p2.download" id="downloadStrategies" name="Download Strategies"/>
7
      </appInfo>
8
      <documentation>
9
         Definition of strategies that understand how to efficiently download software from a set of artifact repositories.
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <complexType>
15
         <sequence minOccurs="1" maxOccurs="unbounded">
16
            <element ref="strategy"/>
17
         </sequence>
18
         <attribute name="point" type="string" use="required">
19
            <annotation>
20
               <documentation>
21
                  
22
               </documentation>
23
            </annotation>
24
         </attribute>
25
         <attribute name="id" type="string">
26
            <annotation>
27
               <documentation>
28
                  
29
               </documentation>
30
            </annotation>
31
         </attribute>
32
         <attribute name="name" type="string">
33
            <annotation>
34
               <documentation>
35
                  
36
               </documentation>
37
               <appInfo>
38
                  <meta.attribute translatable="true"/>
39
               </appInfo>
40
            </annotation>
41
         </attribute>
42
      </complexType>
43
   </element>
44
45
   <element name="strategy">
46
      <complexType>
47
         <attribute name="class" type="string" use="required">
48
            <annotation>
49
               <documentation>
50
                  
51
               </documentation>
52
               <appInfo>
53
                  <meta.attribute kind="java" basedOn=":org.eclipse.equinox.p2.download.strategy.IDownloadStrategy"/>
54
               </appInfo>
55
            </annotation>
56
         </attribute>
57
      </complexType>
58
   </element>
59
60
   <annotation>
61
      <appInfo>
62
         <meta.section type="since"/>
63
      </appInfo>
64
      <documentation>
65
         [Enter the first release in which this extension point appears.]
66
      </documentation>
67
   </annotation>
68
69
   <annotation>
70
      <appInfo>
71
         <meta.section type="examples"/>
72
      </appInfo>
73
      <documentation>
74
         [Enter extension point usage example here.]
75
      </documentation>
76
   </annotation>
77
78
   <annotation>
79
      <appInfo>
80
         <meta.section type="apiInfo"/>
81
      </appInfo>
82
      <documentation>
83
         [Enter API information here.]
84
      </documentation>
85
   </annotation>
86
87
   <annotation>
88
      <appInfo>
89
         <meta.section type="implementation"/>
90
      </appInfo>
91
      <documentation>
92
         [Enter information about supplied implementation of this extension point.]
93
      </documentation>
94
   </annotation>
95
96
   <annotation>
97
      <appInfo>
98
         <meta.section type="copyright"/>
99
      </appInfo>
100
      <documentation>
101
         
102
      </documentation>
103
   </annotation>
104
105
</schema>
(-)src/org/eclipse/equinox/p2/download/strategy/IDownloadStrategyManager.java (+20 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 Genuitec, LLC and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Genuitec, LLC - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.equinox.p2.download.strategy;
12
13
public interface IDownloadStrategyManager {
14
15
	IDownloadStrategy[] getKnownStrategies();
16
17
	void add(IDownloadStrategy strategy);
18
19
	void remove(IDownloadStrategy strategy);
20
}
(-)src/org/eclipse/equinox/internal/p2/download/strategy/ThreadedDownloadStrategy.java (+39 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 Genuitec, LLC and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Genuitec, LLC - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.equinox.internal.p2.download.strategy;
12
13
import org.eclipse.core.runtime.IProgressMonitor;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.equinox.p2.artifact.repository.IArtifactRepository;
16
import org.eclipse.equinox.p2.artifact.repository.IArtifactRepositoryWithRangeSupport;
17
import org.eclipse.equinox.p2.download.strategy.DownloadStrategyRequests;
18
import org.eclipse.equinox.p2.download.strategy.IDownloadStrategy;
19
20
/** 
21
 * Place holder implementation for the threaded download strategy that will utilize
22
 * knowledge about certain artificat repositories for greater overall throughput.
23
 */
24
public class ThreadedDownloadStrategy implements IDownloadStrategy {
25
26
	public IStatus getArtifacts(DownloadStrategyRequests[] requests, IProgressMonitor monitor) {
27
		// TODO Auto-generated method stub
28
		return null;
29
	}
30
31
	public boolean isBetterThan(IDownloadStrategy other, IArtifactRepository artifactRepository) {
32
		// TODO Auto-generated method stub
33
		return false;
34
	}
35
36
	public boolean supportsRepository(IArtifactRepository artifactRepository) {
37
		return artifactRepository instanceof IArtifactRepositoryWithRangeSupport;
38
	}
39
}
(-)src/org/eclipse/equinox/internal/p2/download/strategy/DownloadStrategyManager.java (+48 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 Genuitec, LLC and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Genuitec, LLC - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.equinox.internal.p2.download.strategy;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
import org.eclipse.core.runtime.IConfigurationElement;
16
import org.eclipse.core.runtime.RegistryFactory;
17
import org.eclipse.equinox.internal.p2.download.DownloadActivator;
18
import org.eclipse.equinox.p2.download.strategy.IDownloadStrategy;
19
import org.eclipse.equinox.p2.download.strategy.IDownloadStrategyManager;
20
21
public class DownloadStrategyManager implements IDownloadStrategyManager {
22
23
	private List strategies = new ArrayList();
24
25
	public DownloadStrategyManager() {
26
		IConfigurationElement[] elt = RegistryFactory.getRegistry().getConfigurationElementsFor(DownloadActivator.ID + ".downloadStrategies");
27
		for (int i = 0; i < elt.length; i++) {
28
			try {
29
				strategies.add((IDownloadStrategy) elt[i].createExecutableExtension("class"));
30
			} catch (Exception e) {
31
				// should do something with this
32
				e.printStackTrace();
33
			}
34
		}
35
	}
36
37
	public void add(IDownloadStrategy strategy) {
38
		strategies.add(strategy);
39
	}
40
41
	public void remove(IDownloadStrategy strategy) {
42
		strategies.remove(strategy);
43
	}
44
45
	public IDownloadStrategy[] getKnownStrategies() {
46
		return (IDownloadStrategy[]) strategies.toArray(new IDownloadStrategy[strategies.size()]);
47
	}
48
}

Return to bug 207802