-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an ArtifactManager to allows unified managing of artifacts #590
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...org.eclipse.equinox.p2.artifact.repository/.settings/org.eclipse.pde.ds.annotations.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
dsVersion=V1_4 | ||
eclipse.preferences.version=1 | ||
enabled=true | ||
generateBundleActivationPolicyLazy=true | ||
path=OSGI-INF | ||
validationErrorLevel=error | ||
validationErrorLevel.missingImplicitUnbindMethod=error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
bundles/org.eclipse.equinox.p2.artifact.repository/OSGI-INF/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/org.eclipse.equinox.*.xml |
56 changes: 56 additions & 0 deletions
56
...t.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Christoph Läubrich 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: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.equinox.internal.p2.artifact.repository; | ||
|
||
import java.io.OutputStream; | ||
import java.net.URI; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.equinox.internal.p2.repository.DownloadStatus; | ||
import org.eclipse.equinox.internal.provisional.p2.repository.IStateful; | ||
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; | ||
import org.osgi.annotation.versioning.ProviderType; | ||
|
||
/** | ||
* The artifact manager is responsible for managing artifacts on a per agent | ||
* basis. It possibly caches the data from previous requests to improve | ||
* performance or knows alternative locations to fetch the artifacts. | ||
*/ | ||
@ProviderType | ||
public interface ArtifactManager { | ||
|
||
/** | ||
* Service name for the artifact manager service. | ||
*/ | ||
String SERVICE_NAME = "org.eclipse.equinox.internal.p2.repository.ArtifactManager"; //$NON-NLS-1$ | ||
|
||
/** | ||
* Acquire the artifact described by the given artifact descriptor and writing | ||
* it into the target output stream. Progress is reported on the monitor. If the | ||
* <code>target</code> is an instance of {@link IStateful} the resulting status | ||
* is also reported on the target. | ||
* | ||
* @return IStatus that is a {@link DownloadStatus} if the artifact was | ||
* downloaded from a remote server, or a plain status in other cases | ||
* (including errors). | ||
* @param source An URI of file to download from a remote, this might be a | ||
* mirror of the actual artifact repository | ||
* @param target the {@link OutputStream} where result is written | ||
* @param descriptor the descriptor of the artifact that is about to be | ||
* downloaded | ||
* @param monitor where progress should be reported, might be | ||
* <code>null</code> if no progress reporting is desired | ||
*/ | ||
IStatus getArtifact(URI source, OutputStream target, IArtifactDescriptor descriptor, IProgressMonitor monitor); | ||
} |
56 changes: 56 additions & 0 deletions
56
...eclipse/equinox/internal/p2/artifact/repository/DefaultArtifactManagerServiceFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Christoph Läubrich 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: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.equinox.internal.p2.artifact.repository; | ||
|
||
import java.io.OutputStream; | ||
import java.net.URI; | ||
import org.eclipse.core.runtime.*; | ||
import org.eclipse.equinox.internal.p2.repository.Transport; | ||
import org.eclipse.equinox.p2.core.IProvisioningAgent; | ||
import org.eclipse.equinox.p2.core.spi.AgentServiceName; | ||
import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory; | ||
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; | ||
import org.osgi.service.component.annotations.Component; | ||
|
||
/** | ||
* The default implementation of a {@link ArtifactManager} simply delegates to | ||
* the transport. | ||
*/ | ||
@Component(service = IAgentServiceFactory.class) | ||
@AgentServiceName(ArtifactManager.class) | ||
public class DefaultArtifactManagerServiceFactory implements IAgentServiceFactory { | ||
|
||
@Override | ||
public Object createService(IProvisioningAgent agent) { | ||
return new DefaultArtifactManager(agent); | ||
} | ||
|
||
private static final class DefaultArtifactManager implements ArtifactManager { | ||
private IProvisioningAgent agent; | ||
|
||
public DefaultArtifactManager(IProvisioningAgent agent) { | ||
this.agent = agent; | ||
} | ||
|
||
@Override | ||
public IStatus getArtifact(URI source, OutputStream target, IArtifactDescriptor descriptor, | ||
IProgressMonitor monitor) { | ||
Transport transport = agent.getService(Transport.class); | ||
if (transport == null) { | ||
return Status.CANCEL_STATUS; | ||
} | ||
return transport.downloadArtifact(source, target, descriptor, monitor); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...les/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/spi/AgentServiceName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Christoph Läubrich 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: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.equinox.p2.core.spi; | ||
|
||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.CLASS; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
import org.osgi.service.component.annotations.ComponentPropertyType; | ||
|
||
/** | ||
* This component property type can be used to annotate a declarative service | ||
* component that provides an {@link IAgentServiceFactory} to provides the | ||
* required {@link IAgentServiceFactory#PROP_AGENT_SERVICE_NAME}. | ||
* | ||
* @since 2.13 | ||
*/ | ||
@Retention(CLASS) | ||
@Target(TYPE) | ||
@ComponentPropertyType | ||
public @interface AgentServiceName { | ||
|
||
public static final String PREFIX_ = "p2."; //$NON-NLS-1$ | ||
|
||
Class<?> value(); | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the change is reasonable, I just wanted to mention that renamings that just change the case of some letters in a file name cause funny side-effects on Windows because the file-system is case-insensitive and then git gets confused.
But one just has to get along with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the class is actually new (I just renamed it in the PR for the sake of testing) it hopefully do not confuses windows to much :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate the improved name. It looks like a typo before. 😕