Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: fde831023939f1291405f40ffc4cf1394ca8a558 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*******************************************************************************
 *  Copyright (c) 2007, 2010 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
 *******************************************************************************/
package org.eclipse.equinox.p2.repository.metadata.spi;

import java.net.URI;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.repository.IRepositoryManager;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;

/**
 * A metadata repository factory is responsible for creating and loading instances
 * of a particular type of metadata repository. Factories are provided via the 
 * <tt>org.eclipse.equinox.p2.metadata.repository.metadataRepositories</tt> extension point.
 * @since 2.0
 */
public abstract class MetadataRepositoryFactory {
	private IProvisioningAgent agent;

	/**
	 * Creates and returns a new empty metadata repository of the given type at 
	 * the given location.
	 * 
	 * @param location the location for the new repository
	 * @param name the name of the new repository
	 * @param type the kind of repository to create
	 * @param properties the properties to set on the repository
	 * @return the newly created repository
	 * @throws ProvisionException if the repository could not be created.  Reasons include:
	 * <ul>
	 * <li>The repository type is not supported by this factory.</li>
	 * <li>There was an error writing to the given repository location.</li>
	 * </ul>
	 */
	public abstract IMetadataRepository create(URI location, String name, String type, Map<String, String> properties) throws ProvisionException;

	/**
	 * Returns the provisioning agent associated with this factory, or <code>null</code>
	 * if this factory is not associated with an agent.
	 * @return The provisioning agent, or <code>null</code>
	 */
	protected IProvisioningAgent getAgent() {
		return agent;
	}

	/**
	 * Loads a repository corresponding to the given URL.
	 * <p>
	 * The error code returned in the case of failure is significant. In particular an
	 * error code of {@link ProvisionException#REPOSITORY_FAILED_READ} indicates
	 * that the location definitely identifies a repository of this type, but an error occurred
	 * while loading the repository. The repository manager will not attempt to load
	 * a repository from that location using any other factory.  An error code of
	 * {@link ProvisionException#REPOSITORY_NOT_FOUND} indicates there is no
	 * repository of this type at the given location, and the repository manager is free
	 * to try again with a different repository factory.
	 * </p>
	 * <p>
	 * The flags passed in should be taken as a hint for the type of repository to load.  If
	 * the factory knows it will not load a repository that satisfies these hints, it can fail
	 * fast and return null.<br>
	 * See {@link IRepositoryManager#REPOSITORY_HINT_MODIFIABLE}
	 * </p>
	 * @param location The location of the repository to load
	 * @param flags to consider while loading the repository
	 * @param monitor a progress monitor, or <code>null</code> if progress
	 *    reporting is not desired
	 * @return The loaded metadata repository
	 * @throws ProvisionException if the repository could not be created.  Reasons include:
	 * <ul>
	 * <li>There is no existing repository at that location.</li>
	 * <li>The repository at that location could not be read.</li>
	 * </ul>
	 */
	public abstract IMetadataRepository load(URI location, int flags, IProgressMonitor monitor) throws ProvisionException;

	/**
	 * Sets the provisioning agent associated with this repository factory.
	 * @param agent The provisioning agent
	 */
	public void setAgent(IProvisioningAgent agent) {
		this.agent = agent;
	}
}

Back to the top