Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.virgo.kernel.deployer.p2')
-rw-r--r--org.eclipse.virgo.kernel.deployer.p2/.classpath20
-rw-r--r--org.eclipse.virgo.kernel.deployer.p2/.project33
-rw-r--r--org.eclipse.virgo.kernel.deployer.p2/build.xml9
-rw-r--r--org.eclipse.virgo.kernel.deployer.p2/findbugs-exclude.xml8
-rw-r--r--org.eclipse.virgo.kernel.deployer.p2/ivy.xml39
-rw-r--r--org.eclipse.virgo.kernel.deployer.p2/src/main/java/org/eclipse/virgo/kernel/deployer/p2/VirgoPublisher.java22
-rw-r--r--org.eclipse.virgo.kernel.deployer.p2/src/main/java/org/eclipse/virgo/kernel/deployer/p2/publish/LocalFSVirgoPublisher.java164
-rw-r--r--org.eclipse.virgo.kernel.deployer.p2/src/main/java/org/eclipse/virgo/kernel/deployer/p2/publish/actions/VirgoBundlesAction.java358
-rw-r--r--org.eclipse.virgo.kernel.deployer.p2/src/main/java/org/eclipse/virgo/kernel/deployer/p2/publish/actions/ZippedResourcesPublisherAction.java118
-rw-r--r--org.eclipse.virgo.kernel.deployer.p2/src/main/resources/OSGI-INF/org.eclipse.virgo.kernel.deployer.p2.publisher.xml13
-rw-r--r--org.eclipse.virgo.kernel.deployer.p2/template.mf26
11 files changed, 810 insertions, 0 deletions
diff --git a/org.eclipse.virgo.kernel.deployer.p2/.classpath b/org.eclipse.virgo.kernel.deployer.p2/.classpath
new file mode 100644
index 00000000..50eb4fe6
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.p2/.classpath
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/resources"/>
+ <classpathentry kind="src" path="src/test/java"/>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.7.0.v20110224/org.eclipse.osgi-3.7.0.v20110224.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.7.0.v20110224/org.eclipse.osgi-sources-3.7.0.v20110224.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.core.runtime/3.7.0.v20110110/org.eclipse.core.runtime-3.7.0.v20110110.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.p2.publisher/1.2.0.v20110511/org.eclipse.equinox.p2.publisher-1.2.0.v20110511.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.p2.repository/2.1.0.v20110510/org.eclipse.equinox.p2.repository-2.1.0.v20110510.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.p2.core/2.1.0.v20110502-1955/org.eclipse.equinox.p2.core-2.1.0.v20110502-1955.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.p2.artifact.repository/1.1.100.v20110511-1359/org.eclipse.equinox.p2.artifact.repository-1.1.100.v20110511-1359.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.p2.metadata.repository/1.2.0.v20110511-1359/org.eclipse.equinox.p2.metadata.repository-1.2.0.v20110511-1359.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.common/3.6.0.v20110506/org.eclipse.equinox.common-3.6.0.v20110506.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.equinox.p2.metadata/2.1.0.v20110510/org.eclipse.equinox.p2.metadata-2.1.0.v20110510.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/pdepublishing/1.0.0/pdepublishing-1.0.0.jar"/>
+ <classpathentry kind="var" path="KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi.services/3.3.0.v20110110/org.eclipse.osgi.services-3.3.0.v20110110.jar" sourcepath="/KERNEL_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi.services/3.3.0.v20110110/org.eclipse.osgi.services-sources-3.3.0.v20110110.jar"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/org.eclipse.virgo.kernel.deployer.p2/.project b/org.eclipse.virgo.kernel.deployer.p2/.project
new file mode 100644
index 00000000..f1badaff
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.p2/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.virgo.kernel.deployer.p2</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.virgo.kernel.deployer.p2/build.xml b/org.eclipse.virgo.kernel.deployer.p2/build.xml
new file mode 100644
index 00000000..3f8f2b0b
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.p2/build.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="org.eclipse.virgo.kernel.deployer.p2">
+
+ <property name="findbugs.exclude.file" value="${basedir}/findbugs-exclude.xml"/>
+ <property file="${basedir}/../build.properties"/>
+ <property file="${basedir}/../build.versions"/>
+ <import file="${basedir}/../virgo-build/weaving/default.xml"/>
+
+</project>
diff --git a/org.eclipse.virgo.kernel.deployer.p2/findbugs-exclude.xml b/org.eclipse.virgo.kernel.deployer.p2/findbugs-exclude.xml
new file mode 100644
index 00000000..ca6b7edc
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.p2/findbugs-exclude.xml
@@ -0,0 +1,8 @@
+<FindBugsFilter>
+ <!-- Exclusions -->
+ <Match>
+ <Bug pattern="ES_COMPARING_PARAMETER_STRING_WITH_EQ"/>
+ <Class name="org.eclipse.virgo.kernel.deployer.core.module.StandardModule"/>
+ <Method name="unwrapNull"/>
+ </Match>
+</FindBugsFilter>
diff --git a/org.eclipse.virgo.kernel.deployer.p2/ivy.xml b/org.eclipse.virgo.kernel.deployer.p2/ivy.xml
new file mode 100644
index 00000000..8a61d895
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.p2/ivy.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="http://ivyrep.jayasoft.org/ivy-doc.xsl"?>
+<ivy-module
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://incubator.apache.org/ivy/schemas/ivy.xsd"
+ version="1.3">
+
+ <info organisation="org.eclipse.virgo.kernel" module="${ant.project.name}"/>
+
+ <configurations>
+ <include file="${virgo.build.dir}/common/default-ivy-configurations.xml"/>
+ </configurations>
+
+ <publications>
+ <artifact name="${ant.project.name}"/>
+ <artifact name="${ant.project.name}-sources" type="src" ext="jar"/>
+ </publications>
+
+ <dependencies>
+ <dependency org="org.aspectj" name="com.springsource.org.aspectj.weaver" rev="${org.aspectj}" conf="compile->runtime"/>
+
+ <dependency org="org.eclipse.osgi" name="org.eclipse.osgi" rev="${org.eclipse.osgi}" conf="compile->runtime"/>
+ <dependency org="org.eclipse.osgi" name="org.eclipse.core.runtime" rev="${org.eclipse.core.runtime}" conf="compile->runtime"/>
+ <dependency org="org.eclipse.osgi" name="org.eclipse.osgi.services" rev="${org.eclipse.osgi.services}" conf="compile->runtime"/>
+ <dependency org="org.eclipse.osgi" name="org.eclipse.equinox.p2.publisher" rev="${org.eclipse.equinox.p2.publisher}" conf="compile->runtime"/>
+ <dependency org="org.eclipse.osgi" name="org.eclipse.equinox.p2.repository" rev="${org.eclipse.equinox.p2.repository}" conf="compile->runtime"/>
+ <dependency org="org.eclipse.osgi" name="org.eclipse.equinox.p2.core" rev="${org.eclipse.equinox.p2.core}" conf="compile->runtime"/>
+ <dependency org="org.eclipse.osgi" name="org.eclipse.equinox.p2.artifact.repository" rev="${org.eclipse.equinox.p2.artifact.repository}" conf="compile->runtime"/>
+ <dependency org="org.eclipse.osgi" name="org.eclipse.equinox.p2.metadata.repository" rev="${org.eclipse.equinox.p2.metadata.repository}" conf="compile->runtime"/>
+ <dependency org="org.eclipse.osgi" name="org.eclipse.equinox.common" rev="${org.eclipse.equinox.common}" conf="compile->runtime"/>
+ <dependency org="org.eclipse.osgi" name="org.eclipse.equinox.p2.metadata" rev="${org.eclipse.equinox.p2.metadata}" conf="compile->runtime"/>
+ <dependency org="org.eclipse.osgi" name="org.eclipse.equinox.p2.publisher.eclipse.pdepublishing" rev="1.0.0" conf="provided->runtime"/>
+
+ <!-- Allow Equinox to be upgraded point-wise before rippling -->
+ <override org="org.eclipse.osgi" module="org.eclipse.osgi" rev="${org.eclipse.osgi}"/>
+ </dependencies>
+
+
+</ivy-module>
diff --git a/org.eclipse.virgo.kernel.deployer.p2/src/main/java/org/eclipse/virgo/kernel/deployer/p2/VirgoPublisher.java b/org.eclipse.virgo.kernel.deployer.p2/src/main/java/org/eclipse/virgo/kernel/deployer/p2/VirgoPublisher.java
new file mode 100644
index 00000000..de91d261
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.p2/src/main/java/org/eclipse/virgo/kernel/deployer/p2/VirgoPublisher.java
@@ -0,0 +1,22 @@
+package org.eclipse.virgo.kernel.deployer.p2;
+
+import java.net.URISyntaxException;
+
+import org.eclipse.equinox.p2.core.ProvisionException;
+
+/**
+ * Common interface for all p2 publishers used within Virgo.
+ *
+ * Implementations of this interface are required to be thread safe.
+ */
+public interface VirgoPublisher {
+
+ /**
+ * Publishes a product and its dependencies in a p2 repository
+ * @param sourceLocation - the location of the folder where the product file is
+ * @param targetLocation - the location of the published repository
+ * @throws ProvisionException - when an error during publishing occurs
+ * @throws URISyntaxException - when the locations have wrong syntax
+ */
+ public void publishProduct(String sourceLocation, String targetLocation) throws ProvisionException, URISyntaxException;
+}
diff --git a/org.eclipse.virgo.kernel.deployer.p2/src/main/java/org/eclipse/virgo/kernel/deployer/p2/publish/LocalFSVirgoPublisher.java b/org.eclipse.virgo.kernel.deployer.p2/src/main/java/org/eclipse/virgo/kernel/deployer/p2/publish/LocalFSVirgoPublisher.java
new file mode 100644
index 00000000..84885d9f
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.p2/src/main/java/org/eclipse/virgo/kernel/deployer/p2/publish/LocalFSVirgoPublisher.java
@@ -0,0 +1,164 @@
+package org.eclipse.virgo.kernel.deployer.p2.publish;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.equinox.internal.p2.artifact.repository.ArtifactRepositoryManager;
+import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository;
+import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepositoryFactory;
+import org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager;
+import org.eclipse.equinox.internal.p2.metadata.repository.SimpleMetadataRepositoryFactory;
+import org.eclipse.equinox.internal.p2.publisher.Messages;
+import org.eclipse.equinox.internal.p2.publisher.eclipse.IProductDescriptor;
+import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.publisher.IPublisherAction;
+import org.eclipse.equinox.p2.publisher.IPublisherInfo;
+import org.eclipse.equinox.p2.publisher.Publisher;
+import org.eclipse.equinox.p2.publisher.PublisherInfo;
+import org.eclipse.equinox.p2.publisher.eclipse.ProductAction;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.virgo.kernel.deployer.p2.VirgoPublisher;
+import org.eclipse.virgo.kernel.deployer.p2.publish.actions.VirgoBundlesAction;
+import org.eclipse.virgo.kernel.deployer.p2.publish.actions.ZippedResourcesPublisherAction;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * This {@link VirgoPublisher} handles the local FS publishing of artifacts and products.
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * Thread-safe.
+ */
+public class LocalFSVirgoPublisher implements VirgoPublisher {
+
+ private static final String ENV_PROPERTY = "all.all.all";
+
+ private static final String VIRGO_PRODUCT = "/virgo.product";
+
+ private static final String[][] VIRGO_MAPPING_RULES = new String[][] {
+ { "(& (classifier=osgi.bundle))", "${repoUrl}/${id}_${version}.jar" },
+ { "(& (classifier=binary))", "${repoUrl}/${id}" },
+ { "(& (classifier=org.eclipse.update.feature))", "${repoUrl}/${id}_${version}.jar" } };;
+
+ private final Object monitor = new Object();
+
+ public void activate(ComponentContext context) {
+ }
+
+ public void deactivate(ComponentContext context) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void publishProduct(String sourceLocation, String targetLocation) throws ProvisionException, URISyntaxException {
+ synchronized (this.monitor) {
+ IPublisherInfo info = createPublisherInfo(targetLocation);
+ Publisher publisher = new Publisher(info);
+ publisher.publish(createPublisherActionsForQualifiedArtifacts(sourceLocation), null);
+ publisher.publish(createProductAction(sourceLocation, targetLocation), null);
+ }
+ }
+
+ /**
+ * Create the product publisher action. This action will take care of updating the p2 metadata repository with the products description
+ * @param sourceLocation - the folder where the product file is located
+ * @param targetLocation - the location of the target repository that will be updated with the product file definition
+ * @return - return the {@link ProductAction} that will handle the publishing of the product
+ */
+ private IPublisherAction[] createProductAction(String sourceLocation, String targetLocation) {
+ IProductDescriptor productDescriptor = null;
+ String productFile = sourceLocation + VIRGO_PRODUCT;
+ try {
+ productDescriptor = new ProductFile(productFile);
+ } catch (Exception e) {
+ throw new IllegalArgumentException(NLS.bind(Messages.exception_errorLoadingProductFile, productFile, e.toString()));
+ }
+ return new IPublisherAction[] {new ProductAction(targetLocation, productDescriptor, "tooling", null)};
+ }
+
+ /**
+ * Initializes the publisher info used for the publishing operations.
+ * @param targetLocation - the location where a p2 repository will be created with that {@link IPublisherInfo}.
+ * @return - the {@link IPublisherInfo} that will be used to create a p2 repository in the specified location
+ * @throws URISyntaxException - when the URI for the p2 repository is with wrong syntax
+ */
+ private IPublisherInfo createPublisherInfo(String targetLocation) throws URISyntaxException {
+ targetLocation = targetLocation.startsWith("file:") ? targetLocation : "file:" + targetLocation;
+
+ PublisherInfo pInfo = new PublisherInfo();
+
+ pInfo.setConfigurations(new String[] {ENV_PROPERTY});
+
+ initialisePublisherInfoRepositories(targetLocation, pInfo);
+ pInfo.setArtifactOptions(IPublisherInfo.A_PUBLISH | IPublisherInfo.A_INDEX);
+ return pInfo;
+ }
+
+ /**
+ * Initializes the {@link IPublisherInfo} p2 metadata and artifact repositories on the specified location
+ * @param targetLocation - the location where the p2 repository will be published
+ * @param pInfo - the {@link IPublisherInfo} created for the target p2 repository
+ * @throws URISyntaxException - when the URI for the artifact or metadata p2 repositories is with wrong syntax
+ */
+ @SuppressWarnings("unchecked")
+ private void initialisePublisherInfoRepositories(String targetLocation, PublisherInfo pInfo) throws URISyntaxException {
+ IMetadataRepository metadataRepository = new SimpleMetadataRepositoryFactory().create(new URI(targetLocation), "Virgo Metadata Repository",
+ MetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, Collections.EMPTY_MAP);
+
+ IArtifactRepository artifactRepository = new SimpleArtifactRepositoryFactory().create(new URI(targetLocation), "Virgo Artifact Repository",
+ ArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, Collections.EMPTY_MAP);
+
+ ((SimpleArtifactRepository) artifactRepository).setRules(VIRGO_MAPPING_RULES);
+ ((SimpleArtifactRepository) artifactRepository).initializeAfterLoad(new URI(targetLocation));
+
+ pInfo.setMetadataRepository(metadataRepository);
+ pInfo.setArtifactRepository(artifactRepository);
+ }
+
+ /**
+ * Creates {@link IPublisherAction} for each qualified file at the specified location
+ * @param location - a location containing the artifacts that will be published in a p2 repository
+ * @return - an array of {@link IPublisherAction} that will be used for publishing to a p2 repository
+ */
+ private IPublisherAction[] createPublisherActionsForQualifiedArtifacts(String location) {
+ location = location.startsWith("file:") ? location.substring(5) : location;
+
+ File repository = new File(location);
+ List<File> bundles = new ArrayList<File>();
+ List<File> zippedFiles = new ArrayList<File>();
+
+ if (repository.isDirectory()) { // TODO: handle single artifact as directory
+ for (File file : repository.listFiles()) {
+ if (file.getName().endsWith(".jar") || file.isDirectory()) {
+ bundles.add(file);
+ }
+ if (file.getName().endsWith(".zip")) {
+ zippedFiles.add(file);
+ }
+ }
+ } else {
+ if (location.endsWith(".jar")) {
+ bundles.add(new File(location));
+ }
+ }
+ List<IPublisherAction> publisherActions = new ArrayList<IPublisherAction>();
+ if (bundles.size() > 0) {
+ VirgoBundlesAction bundleAction = new VirgoBundlesAction(bundles.toArray(new File[bundles.size()]));
+ publisherActions.add(bundleAction);
+ }
+ if (zippedFiles.size() > 0) {
+ ZippedResourcesPublisherAction zippedAction = new ZippedResourcesPublisherAction(zippedFiles.toArray(new File[zippedFiles.size()]));
+ publisherActions.add(zippedAction);
+ }
+ return publisherActions.toArray(new IPublisherAction[publisherActions.size()]);
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.p2/src/main/java/org/eclipse/virgo/kernel/deployer/p2/publish/actions/VirgoBundlesAction.java b/org.eclipse.virgo.kernel.deployer.p2/src/main/java/org/eclipse/virgo/kernel/deployer/p2/publish/actions/VirgoBundlesAction.java
new file mode 100644
index 00000000..5083a854
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.p2/src/main/java/org/eclipse/virgo/kernel/deployer/p2/publish/actions/VirgoBundlesAction.java
@@ -0,0 +1,358 @@
+package org.eclipse.virgo.kernel.deployer.p2.publish.actions;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitFragment;
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.metadata.IRequirement;
+import org.eclipse.equinox.p2.metadata.IUpdateDescriptor;
+import org.eclipse.equinox.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitFragmentDescription;
+import org.eclipse.equinox.p2.publisher.IPublisherInfo;
+import org.eclipse.equinox.p2.publisher.IPublisherResult;
+import org.eclipse.equinox.p2.publisher.AdviceFileAdvice;
+import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction;
+import org.eclipse.equinox.p2.publisher.eclipse.IBundleShapeAdvice;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
+import org.eclipse.equinox.spi.p2.publisher.LocalizationHelper;
+import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
+import org.eclipse.osgi.service.resolver.BundleDescription;
+import org.eclipse.osgi.service.resolver.BundleSpecification;
+import org.eclipse.osgi.service.resolver.ExportPackageDescription;
+import org.eclipse.osgi.service.resolver.HostSpecification;
+import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
+import org.osgi.framework.Constants;
+
+/**
+ * This class provides extension to the standard p2 BundlesAction by including the whole manifest in the published metadata.
+ *
+ */
+public class VirgoBundlesAction extends BundlesAction {
+
+ private static final String CAPABILITY_NS_OSGI_BUNDLE = "osgi.bundle"; //$NON-NLS-1$
+ private static final String CAPABILITY_NS_OSGI_FRAGMENT = "osgi.fragment"; //$NON-NLS-1$
+
+ private static final String[] BUNDLE_IU_PROPERTY_MAP = {Constants.BUNDLE_NAME, IInstallableUnit.PROP_NAME, Constants.BUNDLE_DESCRIPTION, IInstallableUnit.PROP_DESCRIPTION, Constants.BUNDLE_VENDOR, IInstallableUnit.PROP_PROVIDER, Constants.BUNDLE_CONTACTADDRESS, IInstallableUnit.PROP_CONTACT, Constants.BUNDLE_DOCURL, IInstallableUnit.PROP_DOC_URL, Constants.BUNDLE_UPDATELOCATION, IInstallableUnit.PROP_BUNDLE_LOCALIZATION, Constants.BUNDLE_LOCALIZATION, IInstallableUnit.PROP_BUNDLE_LOCALIZATION};
+
+ public VirgoBundlesAction(BundleDescription[] bundles) {
+ super(bundles);
+ }
+
+ public VirgoBundlesAction(File[] files) {
+ super(files);
+ }
+
+ @Override
+ protected void generateBundleIUs(BundleDescription[] bundleDescriptions, IPublisherInfo info, IPublisherResult result, IProgressMonitor monitor) {
+ // This assumes that hosts are processed before fragments because for each fragment the host
+ // is queried for the strings that should be translated.
+ for (int i = 0; i < bundleDescriptions.length; i++) {
+ if (monitor.isCanceled())
+ throw new OperationCanceledException();
+
+ BundleDescription bd = bundleDescriptions[i];
+ if (bd != null && bd.getSymbolicName() != null && bd.getVersion() != null) {
+ //First check to see if there is already an IU around for this
+ IInstallableUnit bundleIU = queryForIU(result, bundleDescriptions[i].getSymbolicName(), PublisherHelper.fromOSGiVersion(bd.getVersion()));
+ IArtifactKey key = createBundleArtifactKey(bd.getSymbolicName(), bd.getVersion().toString());
+ if (bundleIU == null) {
+ createAdviceFileAdvice(bundleDescriptions[i], info);
+ // Create the bundle IU according to any shape advice we have
+ bundleIU = createBundleIU(bd, key, info);
+ }
+
+ File location = new File(bd.getLocation());
+ IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(info, key, location);
+ processArtifactPropertiesAdvice(bundleIU, ad, info);
+
+ // Publish according to the shape on disk
+ File bundleLocation = new File(bd.getLocation());
+ if (bundleLocation.isDirectory())
+ publishArtifact(ad, bundleLocation, bundleLocation.listFiles(), info);
+ else
+ publishArtifact(ad, bundleLocation, info);
+
+ IInstallableUnit fragment = null;
+ if (isFragment(bd)) {
+ // TODO: Need a test case for multiple hosts
+ String hostId = bd.getHost().getName();
+ VersionRange hostVersionRange = PublisherHelper.fromOSGiVersionRange(bd.getHost().getVersionRange());
+ IQueryResult<IInstallableUnit> hosts = queryForIUs(result, hostId, hostVersionRange);
+
+ for (Iterator<IInstallableUnit> itor = hosts.iterator(); itor.hasNext();) {
+ IInstallableUnit host = itor.next();
+ String fragmentId = makeHostLocalizationFragmentId(bd.getSymbolicName());
+ fragment = queryForIU(result, fragmentId, PublisherHelper.fromOSGiVersion(bd.getVersion()));
+ if (fragment == null) {
+ String[] externalizedStrings = getExternalizedStrings(host);
+ fragment = createHostLocalizationFragment(bundleIU, bd, hostId, externalizedStrings);
+ }
+ }
+
+ }
+
+ result.addIU(bundleIU, IPublisherResult.ROOT);
+ if (fragment != null)
+ result.addIU(fragment, IPublisherResult.NON_ROOT);
+
+ InstallableUnitDescription[] others = processAdditionalInstallableUnitsAdvice(bundleIU, info);
+ for (int iuIndex = 0; others != null && iuIndex < others.length; iuIndex++) {
+ result.addIU(MetadataFactory.createInstallableUnit(others[iuIndex]), IPublisherResult.ROOT);
+ }
+ }
+ }
+ }
+
+ public static IInstallableUnit createBundleIU(BundleDescription bd, IArtifactKey key, IPublisherInfo info) {
+ @SuppressWarnings("unchecked")
+ Map<String, String> manifest = (Map<String, String>) bd.getUserObject();
+ Map<Locale, Map<String, String>> manifestLocalizations = null;
+ if (manifest != null && bd.getLocation() != null)
+ manifestLocalizations = getManifestLocalizations(manifest, new File(bd.getLocation()));
+ InstallableUnitDescription iu = new MetadataFactory.InstallableUnitDescription();
+ iu.setSingleton(bd.isSingleton());
+ iu.setId(bd.getSymbolicName());
+ iu.setVersion(PublisherHelper.fromOSGiVersion(bd.getVersion()));
+ iu.setFilter(bd.getPlatformFilter());
+ iu.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor(bd.getSymbolicName(), computeUpdateRange(bd.getVersion()), IUpdateDescriptor.NORMAL, null));
+ iu.setArtifacts(new IArtifactKey[] {key});
+ iu.setTouchpointType(PublisherHelper.TOUCHPOINT_OSGI);
+
+ boolean isFragment = bd.getHost() != null;
+ // boolean requiresAFragment = isFragment ? false : requireAFragment(bd, manifest);
+
+ //Process the required bundles
+ BundleSpecification requiredBundles[] = bd.getRequiredBundles();
+ ArrayList<IRequirement> reqsDeps = new ArrayList<IRequirement>();
+ // if (requiresAFragment)
+ // reqsDeps.add(MetadataFactory.createRequiredCapability(CAPABILITY_TYPE_OSGI_FRAGMENTS, bd.getSymbolicName(), VersionRange.emptyRange, null, false, false));
+ if (isFragment)
+ reqsDeps.add(MetadataFactory.createRequirement(CAPABILITY_NS_OSGI_BUNDLE, bd.getHost().getName(), PublisherHelper.fromOSGiVersionRange(bd.getHost().getVersionRange()), null, false, false));
+ for (int j = 0; j < requiredBundles.length; j++)
+ reqsDeps.add(MetadataFactory.createRequirement(CAPABILITY_NS_OSGI_BUNDLE, requiredBundles[j].getName(), PublisherHelper.fromOSGiVersionRange(requiredBundles[j].getVersionRange()), null, requiredBundles[j].isOptional(), false));
+
+ // Process the import packages
+ ImportPackageSpecification osgiImports[] = bd.getImportPackages();
+ for (int i = 0; i < osgiImports.length; i++) {
+ // TODO we need to sort out how we want to handle wild-carded dynamic imports - for now we ignore them
+ ImportPackageSpecification importSpec = osgiImports[i];
+ String importPackageName = importSpec.getName();
+ if (importPackageName.indexOf('*') != -1)
+ continue;
+ VersionRange versionRange = PublisherHelper.fromOSGiVersionRange(importSpec.getVersionRange());
+ //TODO this needs to be refined to take into account all the attribute handled by imports
+ reqsDeps.add(MetadataFactory.createRequirement(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, importPackageName, versionRange, null, isOptional(importSpec), false));
+ }
+ iu.setRequirements(reqsDeps.toArray(new IRequirement[reqsDeps.size()]));
+
+ // Create set of provided capabilities
+ ArrayList<IProvidedCapability> providedCapabilities = new ArrayList<IProvidedCapability>();
+ providedCapabilities.add(PublisherHelper.createSelfCapability(bd.getSymbolicName(), PublisherHelper.fromOSGiVersion(bd.getVersion())));
+ providedCapabilities.add(MetadataFactory.createProvidedCapability(CAPABILITY_NS_OSGI_BUNDLE, bd.getSymbolicName(), PublisherHelper.fromOSGiVersion(bd.getVersion())));
+
+ // Process the export package
+ ExportPackageDescription exports[] = bd.getExportPackages();
+ for (int i = 0; i < exports.length; i++) {
+ //TODO make sure that we support all the refinement on the exports
+ providedCapabilities.add(MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, exports[i].getName(), PublisherHelper.fromOSGiVersion(exports[i].getVersion())));
+ }
+ // Here we add a bundle capability to identify bundles
+ if (manifest != null && manifest.containsKey("Eclipse-SourceBundle")) //$NON-NLS-1$
+ providedCapabilities.add(SOURCE_BUNDLE_CAPABILITY);
+ else
+ providedCapabilities.add(BUNDLE_CAPABILITY);
+ if (isFragment)
+ providedCapabilities.add(MetadataFactory.createProvidedCapability(CAPABILITY_NS_OSGI_FRAGMENT, bd.getHost().getName(), PublisherHelper.fromOSGiVersion(bd.getVersion())));
+
+ if (manifestLocalizations != null) {
+ for (Entry<Locale, Map<String, String>> locEntry : manifestLocalizations.entrySet()) {
+ Locale locale = locEntry.getKey();
+ Map<String, String> translatedStrings = locEntry.getValue();
+ for (Entry<String, String> entry : translatedStrings.entrySet()) {
+ iu.setProperty(locale.toString() + '.' + entry.getKey(), entry.getValue());
+ }
+ providedCapabilities.add(PublisherHelper.makeTranslationCapability(bd.getSymbolicName(), locale));
+ }
+ }
+ iu.setCapabilities(providedCapabilities.toArray(new IProvidedCapability[providedCapabilities.size()]));
+ processUpdateDescriptorAdvice(iu, info);
+ processCapabilityAdvice(iu, info);
+
+ // Set certain properties from the manifest header attributes as IU properties.
+ // The values of these attributes may be localized (strings starting with '%')
+ // with the translated values appearing in the localization IU fragments
+ // associated with the bundle IU.
+ if (manifest != null) {
+ int i = 0;
+ while (i < BUNDLE_IU_PROPERTY_MAP.length) {
+ if (manifest.containsKey(BUNDLE_IU_PROPERTY_MAP[i])) {
+ String value = manifest.get(BUNDLE_IU_PROPERTY_MAP[i]);
+ if (value != null && value.length() > 0) {
+ iu.setProperty(BUNDLE_IU_PROPERTY_MAP[i + 1], value);
+ }
+ }
+ i += 2;
+ }
+ }
+
+ // Define the immutable metadata for this IU. In this case immutable means
+ // that this is something that will not impact the configuration.
+ Map<String, String> touchpointData = new HashMap<String, String>();
+ touchpointData.put("manifest", toManifestString(manifest)); //$NON-NLS-1$
+ if (isDir(bd, info))
+ touchpointData.put("zipped", "true"); //$NON-NLS-1$ //$NON-NLS-2$
+ processTouchpointAdvice(iu, touchpointData, info);
+
+ processInstallableUnitPropertiesAdvice(iu, info);
+ return MetadataFactory.createInstallableUnit(iu);
+ }
+
+ private static String toManifestString(Map<String, String> p) {
+ if (p == null)
+ return null;
+ StringBuffer result = new StringBuffer();
+ for (String key : p.keySet()) {
+ String value = p.get(key);
+ if (value != null)
+ result.append(key).append(": ").append(value).append('\n'); //$NON-NLS-1$
+ }
+ return result.length() == 0 ? null : result.toString();
+ }
+
+ private static boolean isOptional(ImportPackageSpecification importedPackage) {
+ if (importedPackage.getDirective(Constants.RESOLUTION_DIRECTIVE).equals(ImportPackageSpecification.RESOLUTION_DYNAMIC) || importedPackage.getDirective(Constants.RESOLUTION_DIRECTIVE).equals(ImportPackageSpecification.RESOLUTION_OPTIONAL))
+ return true;
+ return false;
+ }
+
+ static VersionRange computeUpdateRange(org.osgi.framework.Version base) {
+ VersionRange updateRange = null;
+ if (!base.equals(org.osgi.framework.Version.emptyVersion)) {
+ updateRange = new VersionRange(Version.emptyVersion, true, PublisherHelper.fromOSGiVersion(base), false);
+ } else {
+ updateRange = VersionRange.emptyRange;
+ }
+ return updateRange;
+ }
+
+ private static boolean isDir(BundleDescription bundle, IPublisherInfo info) {
+ Collection<IBundleShapeAdvice> advice = info.getAdvice(null, true, bundle.getSymbolicName(), PublisherHelper.fromOSGiVersion(bundle.getVersion()), IBundleShapeAdvice.class);
+ // if the advice has a shape, use it
+ if (advice != null && !advice.isEmpty()) {
+ // we know there is some advice but if there is more than one, take the first.
+ String shape = advice.iterator().next().getShape();
+ if (shape != null)
+ return shape.equals(IBundleShapeAdvice.DIR);
+ }
+ // otherwise go with whatever we figured out from the manifest or the shape on disk
+ @SuppressWarnings("unchecked")
+ Map<String, String> manifest = (Map<String, String>) bundle.getUserObject();
+ String format = manifest.get(BUNDLE_SHAPE);
+ return DIR.equals(format);
+ }
+
+ // Return a map from locale to property set for the manifest localizations
+ // from the given bundle directory and given bundle localization path/name
+ // manifest property value.
+ private static Map<Locale, Map<String, String>> getManifestLocalizations(Map<String, String> manifest, File bundleLocation) {
+ Map<Locale, Map<String, String>> localizations;
+ Locale defaultLocale = null; // = Locale.ENGLISH; // TODO: get this from GeneratorInfo
+ String[] bundleManifestValues = getManifestCachedValues(manifest);
+ String bundleLocalization = bundleManifestValues[BUNDLE_LOCALIZATION_INDEX]; // Bundle localization is the last one in the list
+
+ if ("jar".equalsIgnoreCase(new Path(bundleLocation.getName()).getFileExtension()) && //$NON-NLS-1$
+ bundleLocation.isFile()) {
+ localizations = LocalizationHelper.getJarPropertyLocalizations(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
+ //localizations = getJarManifestLocalization(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
+ } else {
+ localizations = LocalizationHelper.getDirPropertyLocalizations(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
+ // localizations = getDirManifestLocalization(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues);
+ }
+
+ return localizations;
+ }
+
+ private void createAdviceFileAdvice(BundleDescription bundleDescription, IPublisherInfo publisherInfo) {
+ String location = bundleDescription.getLocation();
+ if (location == null)
+ return;
+
+ AdviceFileAdvice advice = new AdviceFileAdvice(bundleDescription.getSymbolicName(), PublisherHelper.fromOSGiVersion(bundleDescription.getVersion()), new Path(location), AdviceFileAdvice.BUNDLE_ADVICE_FILE);
+ if (advice.containsAdvice())
+ publisherInfo.addAdvice(advice);
+
+ }
+
+ private boolean isFragment(BundleDescription bd) {
+ return (bd.getHost() != null ? true : false);
+ }
+
+ /**
+ * @param id
+ * @return the id for the iu fragment containing localized properties
+ * for the fragment with the given id.
+ */
+ private static String makeHostLocalizationFragmentId(String id) {
+ return id + ".translated_host_properties"; //$NON-NLS-1$
+ }
+
+ private IInstallableUnitFragment createHostLocalizationFragment(IInstallableUnit bundleIU, BundleDescription bd, String hostId, String[] hostBundleManifestValues) {
+ Map<Locale, Map<String, String>> hostLocalizations = getHostLocalizations(new File(bd.getLocation()), hostBundleManifestValues);
+ if (hostLocalizations == null || hostLocalizations.isEmpty())
+ return null;
+ return createLocalizationFragmentOfHost(bd, hostId, hostBundleManifestValues, hostLocalizations);
+ }
+
+ /*
+ * @param hostId
+ * @param bd
+ * @param locale
+ * @param localizedStrings
+ * @return installableUnitFragment
+ */
+ private static IInstallableUnitFragment createLocalizationFragmentOfHost(BundleDescription bd, String hostId, String[] hostManifestValues, Map<Locale, Map<String, String>> hostLocalizations) {
+ InstallableUnitFragmentDescription fragment = new MetadataFactory.InstallableUnitFragmentDescription();
+ String fragmentId = makeHostLocalizationFragmentId(bd.getSymbolicName());
+ fragment.setId(fragmentId);
+ fragment.setVersion(PublisherHelper.fromOSGiVersion(bd.getVersion())); // TODO: is this a meaningful version?
+
+ HostSpecification hostSpec = bd.getHost();
+ IRequirement[] hostReqs = new IRequirement[] {MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, hostSpec.getName(), PublisherHelper.fromOSGiVersionRange(hostSpec.getVersionRange()), null, false, false, false)};
+ fragment.setHost(hostReqs);
+
+ fragment.setSingleton(true);
+ fragment.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString());
+
+ // Create a provided capability for each locale and add the translated properties.
+ ArrayList<IProvidedCapability> providedCapabilities = new ArrayList<IProvidedCapability>(hostLocalizations.keySet().size());
+ providedCapabilities.add(PublisherHelper.createSelfCapability(fragmentId, fragment.getVersion()));
+ for (Entry<Locale, Map<String, String>> localeEntry : hostLocalizations.entrySet()) {
+ Locale locale = localeEntry.getKey();
+ Map<String, String> translatedStrings = localeEntry.getValue();
+ for (Entry<String, String> entry : translatedStrings.entrySet()) {
+ fragment.setProperty(locale.toString() + '.' + entry.getKey(), entry.getValue());
+ }
+ providedCapabilities.add(PublisherHelper.makeTranslationCapability(hostId, locale));
+ }
+ fragment.setCapabilities(providedCapabilities.toArray(new IProvidedCapability[providedCapabilities.size()]));
+
+ return MetadataFactory.createInstallableUnitFragment(fragment);
+ }
+
+}
diff --git a/org.eclipse.virgo.kernel.deployer.p2/src/main/java/org/eclipse/virgo/kernel/deployer/p2/publish/actions/ZippedResourcesPublisherAction.java b/org.eclipse.virgo.kernel.deployer.p2/src/main/java/org/eclipse/virgo/kernel/deployer/p2/publish/actions/ZippedResourcesPublisherAction.java
new file mode 100644
index 00000000..d7f5761e
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.p2/src/main/java/org/eclipse/virgo/kernel/deployer/p2/publish/actions/ZippedResourcesPublisherAction.java
@@ -0,0 +1,118 @@
+
+package org.eclipse.virgo.kernel.deployer.p2.publish.actions;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
+import org.eclipse.equinox.internal.p2.publisher.Messages;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.publisher.AbstractPublisherAction;
+import org.eclipse.equinox.p2.publisher.IPublisherAction;
+import org.eclipse.equinox.p2.publisher.IPublisherInfo;
+import org.eclipse.equinox.p2.publisher.IPublisherResult;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
+import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
+
+/**
+ * Publishes a zipped resource artifact
+ * <strong>Concurrent Semantics</strong><br />
+ * Thread-safe.
+ */
+public class ZippedResourcesPublisherAction extends AbstractPublisherAction {
+
+ private static final Version DEFAULT_VERSION = Version.createOSGi(1, 0, 0);
+
+ private static final String ZIPPED_RESOURCES_NAME = "zipped.resources";
+
+ private final File[] locations;
+
+ private final Object monitor = new Object();
+
+ public ZippedResourcesPublisherAction(File[] locations) {
+ this.locations = locations;
+ }
+
+ /**
+ * Executes the action, resulting in a published artifact and metadata for it
+ *
+ * @param publisherInfo - initialized {@link IPublisherInfo} with repositories to be used by this {@link IPublisherAction}
+ * @param results - {@link IPublisherResult} that will be passed on the next publishing stages
+ * @param monitor - {@link IProgressMonitor} used for monitoring the progress of this action, can be <b>null</b>
+ * @return - the {@link IStatus} containing the result of the operation
+ */
+ @Override
+ public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
+ if (this.locations == null) {
+ throw new IllegalStateException(Messages.exception_noBundlesOrLocations);
+ }
+ synchronized (this.monitor) {
+ setPublisherInfo(publisherInfo);
+ try {
+ publishZippedIUs(publisherInfo, results, monitor);
+ } catch (OperationCanceledException e) {
+ return Status.CANCEL_STATUS;
+ }
+ }
+ return Status.OK_STATUS;
+ }
+
+ private void publishZippedIUs(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
+
+ InstallableUnitDescription iuDescription = createZippedResourceIUDescriptionShell();
+
+ addZippedResourcesToIUDescription(publisherInfo, iuDescription);
+
+ setTouchpointInstructionsToIUDescription(iuDescription);
+
+ results.addIU(MetadataFactory.createInstallableUnit(iuDescription), IPublisherResult.ROOT);
+
+ }
+
+ private void setTouchpointInstructionsToIUDescription(InstallableUnitDescription iuDescription) {
+ Map<String, String> touchpointData = new HashMap<String, String>();
+ // the install folder is moved two folders up in order to ensure Virgo's root structure is kept the same
+ touchpointData.put("install", "unzip(source:@artifact, target:${installFolder}/../../);");
+ touchpointData.put("uninstall", "cleanupzip(source:@artifact, target:${installFolder}/../../);");
+ iuDescription.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
+ }
+
+ private void addZippedResourcesToIUDescription(IPublisherInfo publisherInfo, InstallableUnitDescription iuDescription) {
+ List<IArtifactKey> zippedArtifacts = new ArrayList<IArtifactKey>();
+
+ for (File zippedFile : this.locations) {
+ IArtifactKey key = new ArtifactKey(PublisherHelper.BINARY_ARTIFACT_CLASSIFIER, zippedFile.getName(), DEFAULT_VERSION);
+ IArtifactDescriptor zipDescriptor = PublisherHelper.createArtifactDescriptor(publisherInfo, key, zippedFile);
+ publishArtifact(zipDescriptor, zippedFile, publisherInfo);
+ zippedArtifacts.add(key);
+ }
+
+ iuDescription.setArtifacts(zippedArtifacts.toArray(new IArtifactKey[zippedArtifacts.size()]));
+ }
+
+ private InstallableUnitDescription createZippedResourceIUDescriptionShell() {
+ InstallableUnitDescription iuDescription = new MetadataFactory.InstallableUnitDescription();
+ iuDescription.setId(ZIPPED_RESOURCES_NAME);
+ iuDescription.setVersion(DEFAULT_VERSION);
+
+ ArrayList<IProvidedCapability> providedCapabilities = new ArrayList<IProvidedCapability>();
+ IProvidedCapability p2IUCapability = MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, iuDescription.getId(),
+ DEFAULT_VERSION);
+ providedCapabilities.add(p2IUCapability);
+ iuDescription.setCapabilities(providedCapabilities.toArray(new IProvidedCapability[providedCapabilities.size()]));
+ iuDescription.setTouchpointType(MetadataFactory.createTouchpointType("org.eclipse.equinox.p2.native", DEFAULT_VERSION));
+ return iuDescription;
+ }
+}
diff --git a/org.eclipse.virgo.kernel.deployer.p2/src/main/resources/OSGI-INF/org.eclipse.virgo.kernel.deployer.p2.publisher.xml b/org.eclipse.virgo.kernel.deployer.p2/src/main/resources/OSGI-INF/org.eclipse.virgo.kernel.deployer.p2.publisher.xml
new file mode 100644
index 00000000..bcc3dc10
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.p2/src/main/resources/OSGI-INF/org.eclipse.virgo.kernel.deployer.p2.publisher.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
+ immediate="true" name="org.eclipse.virgo.kernel.deployer.p2.publisher">
+ <implementation class="org.eclipse.virgo.kernel.deployer.p2.publish.LocalFSVirgoPublisher" />
+
+ <reference name="IProvisioningAgent"
+ interface="org.eclipse.equinox.p2.core.IProvisioningAgent"
+ policy="static"/>
+
+ <service>
+ <provide interface="org.eclipse.virgo.kernel.deployer.p2.VirgoPublisher"/>
+ </service>
+</scr:component> \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer.p2/template.mf b/org.eclipse.virgo.kernel.deployer.p2/template.mf
new file mode 100644
index 00000000..898ea3ae
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.p2/template.mf
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Virgo Kernel P2 Deployer
+Bundle-SymbolicName: org.eclipse.virgo.kernel.deployer.p2
+Bundle-Version: 3.0.0
+Service-Component: OSGI-INF/org.eclipse.virgo.kernel.deployer.p2.publisher.xml
+Import-Template:
+ org.osgi.framework.*;version="0",
+ org.eclipse.osgi.*;version="0",
+ org.osgi.service.*;version="0",
+ org.eclipse.equinox.p2.core;version="0",
+ org.eclipse.equinox.internal.p2.artifact.repository;version="0",
+ org.eclipse.equinox.internal.p2.artifact.repository.simple;version="0",
+ org.eclipse.equinox.internal.p2.metadata.*;version="0",
+ org.eclipse.equinox.internal.p2.publisher;version="0",
+ org.eclipse.equinox.internal.p2.publisher.eclipse;version="0",
+ org.eclipse.equinox.p2.publisher;version="0",
+ org.eclipse.equinox.p2.publisher.eclipse;version="0",
+ org.eclipse.equinox.p2.repository.artifact;version="0",
+ org.eclipse.equinox.p2.repository.metadata;version="0",
+ org.eclipse.core.runtime;version="0",
+ org.eclipse.equinox.p2.metadata.*;version="0",
+ org.eclipse.equinox.p2.query;version="0",
+ org.eclipse.equinox.spi.p2.publisher;version="0"
+Excluded-Exports:
+ *.internal.*

Back to the top