Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.metadata.repository')
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/.classpath2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/.externalToolBuilders/org.eclipse.equinox.p2.metadata.reposiroy buildAntTasks.xml.launch9
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/.settings/org.eclipse.jdt.core.prefs14
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF45
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/OSGI-INF/repositoryManager.xml2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/build.properties2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/p2 tools - mirror metadata.launch24
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/plugin.xml21
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/MirrorApplication.java175
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/Mirroring.java64
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/RangeQuery.java50
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/VersionRangedName.java53
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/Activator.java78
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CacheManager.java34
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java79
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepositoryFactory.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/IUMap.java107
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java63
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryComponent.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java41
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java72
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/SimpleMetadataRepositoryFactory.java (renamed from bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/metadata/repository/SimpleMetadataRepositoryFactory.java)21
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/URLMetadataRepository.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java263
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java165
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/XMLConstants.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/p2/metadata/repository/IMetadataRepository.java80
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/p2/metadata/repository/IMetadataRepositoryManager.java156
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/metadata/repository/AbstractMetadataRepository.java74
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/metadata/repository/MetadataRepositoryFactory.java100
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/metadata/repository/RepositoryReference.java57
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/AddChildTask.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/CreateCompositeMetadataRepositoryTask.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/MirrorApplicationTask.java128
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveChildTask.java7
35 files changed, 571 insertions, 1509 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/.classpath b/bundles/org.eclipse.equinox.p2.metadata.repository/.classpath
index ef379494d..834ea833e 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/.classpath
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" output="bin_ant" path="src_ant"/>
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/.externalToolBuilders/org.eclipse.equinox.p2.metadata.reposiroy buildAntTasks.xml.launch b/bundles/org.eclipse.equinox.p2.metadata.repository/.externalToolBuilders/org.eclipse.equinox.p2.metadata.reposiroy buildAntTasks.xml.launch
index 864bdafe5..d3596d85e 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/.externalToolBuilders/org.eclipse.equinox.p2.metadata.reposiroy buildAntTasks.xml.launch
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/.externalToolBuilders/org.eclipse.equinox.p2.metadata.reposiroy buildAntTasks.xml.launch
@@ -1,12 +1,11 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
+<?xml version="1.0" encoding="UTF-8"?><launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.equinox.p2.metadata.repository/buildAntTasks.xml"/>
+<listEntry value="/org.eclipse.equinox.p2.metadata.repository"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="1"/>
+<listEntry value="4"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
@@ -15,4 +14,4 @@
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/org.eclipse.equinox.p2.metadata.repository/buildAntTasks.xml}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
-</launchConfiguration>
+</launchConfiguration> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.p2.metadata.repository/.settings/org.eclipse.jdt.core.prefs
index 904df3197..6a7984c9b 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Fri Feb 22 11:22:59 EST 2008
+#Mon Dec 28 00:17:37 CET 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
@@ -7,24 +7,24 @@ org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
org.eclipse.jdt.core.circularClasspath=error
org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=jsr14
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.maxProblemPerUnit=1000
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=error
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
@@ -71,7 +71,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=en
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF
index 45b9a8093..fcca9dedf 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF
@@ -4,37 +4,16 @@ Bundle-SymbolicName: org.eclipse.equinox.p2.metadata.repository;singleton:=true
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
-Bundle-Version: 1.0.100.qualifier
-Export-Package: org.eclipse.equinox.internal.p2.metadata.mirror;x-internal:=true,
- org.eclipse.equinox.internal.p2.metadata.repository;
+Bundle-Version: 1.1.0.qualifier
+Export-Package: org.eclipse.equinox.internal.p2.metadata.repository;
x-friends:="org.eclipse.equinox.p2.engine,
org.eclipse.equinox.p2.metadata.generator,
org.eclipse.equinox.p2.publisher,
org.eclipse.equinox.p2.reconciler.dropins,
org.eclipse.equinox.p2.ui,
- org.eclipse.equinox.p2.updatesite",
- org.eclipse.equinox.internal.p2.metadata.repository.io;x-friends:="org.eclipse.equinox.p2.engine",
- org.eclipse.equinox.internal.provisional.p2.metadata.repository;
- x-friends:="org.eclipse.equinox.p2.console,
- org.eclipse.equinox.p2.director,
- org.eclipse.equinox.p2.director.app,
- org.eclipse.equinox.p2.directorywatcher,
- org.eclipse.equinox.p2.engine,
- org.eclipse.equinox.p2.extensionlocation,
- org.eclipse.equinox.p2.installer,
- org.eclipse.equinox.p2.metadata.generator,
- org.eclipse.equinox.p2.publisher,
- org.eclipse.equinox.p2.reconciler.dropins,
- org.eclipse.equinox.p2.ui,
- org.eclipse.equinox.p2.ui.admin,
- org.eclipse.equinox.p2.ui.sdk,
- org.eclipse.equinox.p2.updatechecker,
org.eclipse.equinox.p2.updatesite,
- org.eclipse.pde.ui,
- org.eclipse.equinox.p2.touchpoint.eclipse,
- org.eclipse.equinox.p2.repository.tools,
- org.eclipse.pde.core",
- org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository;x-friends:="org.eclipse.equinox.p2.extensionlocation,org.eclipse.equinox.p2.updatesite,org.eclipse.equinox.p2.engine"
+ org.eclipse.equinox.p2.extensionlocation",
+ org.eclipse.equinox.internal.p2.metadata.repository.io;x-friends:="org.eclipse.equinox.p2.engine"
Import-Package: javax.xml.parsers,
org.eclipse.ecf.core.util,
org.eclipse.equinox.app;resolution:=optional,
@@ -43,22 +22,28 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.internal.p2.persistence,
org.eclipse.equinox.internal.p2.repository,
org.eclipse.equinox.internal.p2.repository.helpers,
- org.eclipse.equinox.internal.provisional.p2.core,
org.eclipse.equinox.internal.provisional.p2.core.eventbus,
- org.eclipse.equinox.internal.provisional.p2.core.location,
org.eclipse.equinox.internal.provisional.p2.metadata,
- org.eclipse.equinox.internal.provisional.p2.metadata.query,
org.eclipse.equinox.internal.provisional.p2.repository,
- org.eclipse.equinox.internal.provisional.spi.p2.repository,
org.eclipse.equinox.p2.core,
org.eclipse.equinox.p2.core.spi,
+ org.eclipse.equinox.p2.metadata,
+ org.eclipse.equinox.p2.metadata.expression,
+ org.eclipse.equinox.p2.metadata.query,
+ org.eclipse.equinox.p2.query,
+ org.eclipse.equinox.p2.repository,
+ org.eclipse.equinox.p2.repository.metadata,
+ org.eclipse.equinox.p2.repository.metadata.spi,
+ org.eclipse.equinox.p2.repository.spi,
org.eclipse.osgi.util;version="1.1.0",
org.osgi.framework;version="1.3.0",
+ org.osgi.service.prefs;version="1.1.1",
org.osgi.util.tracker;version="1.3.0",
org.xml.sax
Bundle-Activator: org.eclipse.equinox.internal.p2.metadata.repository.Activator
Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: J2SE-1.4,
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,
+ J2SE-1.4,
CDC-1.1/Foundation-1.1
Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.5.0,4.0.0)",
org.eclipse.equinox.registry,
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/OSGI-INF/repositoryManager.xml b/bundles/org.eclipse.equinox.p2.metadata.repository/OSGI-INF/repositoryManager.xml
index 11fb66f15..fdf2579b5 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/OSGI-INF/repositoryManager.xml
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/OSGI-INF/repositoryManager.xml
@@ -4,5 +4,5 @@
<service>
<provide interface="org.eclipse.equinox.p2.core.spi.IAgentServiceFactory"/>
</service>
- <property name="p2.agent.servicename" type="String" value="org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager"/>
+ <property name="p2.agent.servicename" type="String" value="org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager"/>
</scr:component> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/build.properties b/bundles/org.eclipse.equinox.p2.metadata.repository/build.properties
index 3e90a6c41..ffda85291 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/build.properties
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/build.properties
@@ -24,3 +24,5 @@ jars.compile.order = .,\
ant_tasks/metadataRepository-ant.jar
source.ant_tasks/metadataRepository-ant.jar = src_ant/
output.ant_tasks/metadataRepository-ant.jar = bin_ant/
+javacTarget=jsr14
+javacSource=1.5
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/p2 tools - mirror metadata.launch b/bundles/org.eclipse.equinox.p2.metadata.repository/p2 tools - mirror metadata.launch
deleted file mode 100644
index 4d7cb3c6a..000000000
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/p2 tools - mirror metadata.launch
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.pde.ui.EquinoxLauncher">
-<booleanAttribute key="append.args" value="true"/>
-<booleanAttribute key="automaticAdd" value="false"/>
-<booleanAttribute key="automaticValidate" value="false"/>
-<stringAttribute key="bootstrap" value=""/>
-<stringAttribute key="checked" value="[NONE]"/>
-<booleanAttribute key="clearConfig" value="false"/>
-<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/p2 tools - mirror metadata"/>
-<booleanAttribute key="default_auto_start" value="false"/>
-<intAttribute key="default_start_level" value="4"/>
-<booleanAttribute key="includeOptional" value="false"/>
-<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
-<stringAttribute key="org.eclipse.jdt.launching.JAVA_COMMAND" value="java"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-console -consolelog -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication&#13;&#10;-source http://download.eclipse.org/eclipse/updates/3.4milestones/&#13;&#10;-destination file:c:/p2"/>
-<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
-<stringAttribute key="pde.version" value="3.3"/>
-<booleanAttribute key="show_selected_only" value="false"/>
-<stringAttribute key="target_bundles" value="org.eclipse.equinox.security@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.app@default:true,org.eclipse.osgi.services@default:default,org.eclipse.osgi@:,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.common@default:default,org.eclipse.equinox.registry@default:default,javax.servlet@default:default,org.eclipse.core.jobs@default:default"/>
-<booleanAttribute key="tracing" value="false"/>
-<booleanAttribute key="useDefaultConfigArea" value="true"/>
-<booleanAttribute key="useNamedJRE" value="true"/>
-<stringAttribute key="workspace_bundles" value="org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.ecf.provider.filetransfer@default:default,org.sat4j.pb@default:default,org.eclipse.equinox.simpleconfigurator@default:true,org.eclipse.equinox.p2.director@default:default,org.sat4j.core@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.p2.console@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.ecf@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.p2.jarprocessor@default:default"/>
-</launchConfiguration>
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/plugin.xml b/bundles/org.eclipse.equinox.p2.metadata.repository/plugin.xml
index c1bac455c..3deee9519 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/plugin.xml
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/plugin.xml
@@ -4,20 +4,9 @@
<extension-point id="metadataRepositories" name="Metadata Repositories" schema="schema/metadataRepositories.exsd"/>
<extension id="simpleRepository" point="org.eclipse.equinox.p2.metadata.repository.metadataRepositories">
<filter suffix="content.xml"/>
- <factory class="org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.SimpleMetadataRepositoryFactory"/>
- </extension>
- <extension
- id="mirrorApplication"
- point="org.eclipse.core.runtime.applications">
- <application
- cardinality="1"
- thread="main"
- visible="true">
- <run
- class="org.eclipse.equinox.internal.p2.metadata.mirror.MirrorApplication">
- </run>
- </application>
+ <factory class="org.eclipse.equinox.internal.p2.metadata.repository.SimpleMetadataRepositoryFactory"/>
</extension>
+
<extension id="compositeRepository" point="org.eclipse.equinox.p2.metadata.repository.metadataRepositories">
<filter suffix="compositeContent.xml"/>
<factory class="org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepositoryFactory"/>
@@ -36,12 +25,6 @@
class="org.eclipse.equinox.internal.p2.metadata.repository.ant.CreateCompositeMetadataRepositoryTask">
</antTask>
- <antTask
- library="ant_tasks/metadataRepository-ant.jar"
- name="p2.metadata.mirror"
- class="org.eclipse.equinox.internal.p2.metadata.repository.ant.MirrorApplicationTask">
- </antTask>
-
<antTask
library="ant_tasks/metadataRepository-ant.jar"
name="p2.composite.metadata.repository.remove"
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/MirrorApplication.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/MirrorApplication.java
deleted file mode 100644
index 535fed636..000000000
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/MirrorApplication.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Code 9 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.metadata.mirror;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.*;
-import org.eclipse.core.runtime.URIUtil;
-import org.eclipse.equinox.app.IApplication;
-import org.eclipse.equinox.app.IApplicationContext;
-import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.p2.metadata.repository.Activator;
-import org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager;
-import org.eclipse.equinox.internal.p2.repository.helpers.RepositoryHelper;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
-
-/**
- * An application that performs mirroring of artifacts between repositories.
- */
-public class MirrorApplication implements IApplication {
-
- private String[] rootSpecs;
- private URI sourceLocation;
- private URI destinationLocation;
- private IMetadataRepository source;
- private IMetadataRepository destination;
- private boolean transitive = false;
- private boolean append = true;
- private IMetadataRepositoryManager cachedManager;
- private boolean sourceLoaded = false;
- private boolean destinationLoaded = false;
- private String destinationName;
-
- /**
- * Convert a list of tokens into an array. The list separator has to be
- * specified.
- */
- public static String[] getArrayArgsFromString(String list, String separator) {
- if (list == null || list.trim().equals("")) //$NON-NLS-1$
- return new String[0];
- List result = new ArrayList();
- for (StringTokenizer tokens = new StringTokenizer(list, separator); tokens.hasMoreTokens();) {
- String token = tokens.nextToken().trim();
- if (!token.equals("")) { //$NON-NLS-1$
- if ((token.indexOf('[') >= 0 || token.indexOf('(') >= 0) && tokens.hasMoreTokens())
- result.add(token + separator + tokens.nextToken());
- else
- result.add(token);
- }
- }
- return (String[]) result.toArray(new String[result.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
- */
- public Object start(IApplicationContext context) throws Exception {
- try {
- initializeFromArguments((String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS));
- setupRepositories();
- new Mirroring().mirror(source, destination, rootSpecs, transitive);
- return IApplication.EXIT_OK;
- } catch (Exception e) {
- System.err.println(e.getMessage());
- throw e;
- } finally {
- //if the repository was not already loaded before the mirror application started, close it.
- if (!sourceLoaded && sourceLocation != null)
- getManager().removeRepository(sourceLocation);
- if (!destinationLoaded && destinationLocation != null)
- getManager().removeRepository(destinationLocation);
- }
- }
-
- private void setupRepositories() throws ProvisionException {
- if (destinationLocation == null || sourceLocation == null)
- throw new IllegalStateException("Must specify a source and destination"); //$NON-NLS-1$
-
- //Check if repositories are already loaded
- //TODO modify the contains statement once the API is available
- sourceLoaded = getManager().contains(sourceLocation);
- //TODO modify the contains statement once the API is available
- destinationLoaded = getManager().contains(destinationLocation);
-
- //must execute before initializeDestination is called
- source = getManager().loadRepository(sourceLocation, 0, null);
- destination = initializeDestination();
- }
-
- /*
- * Return the metadata repository manager. We need to check the service here
- * as well as creating one manually in case we are running a stand-alone application
- * in which no one has registered a manager yet.
- */
- private IMetadataRepositoryManager getManager() {
- if (cachedManager != null)
- return cachedManager;
- IMetadataRepositoryManager result = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
- // service not available... create one and hang onto it
- if (result == null) {
- cachedManager = new MetadataRepositoryManager();
- result = cachedManager;
- }
- return result;
- }
-
- private IMetadataRepository initializeDestination() throws ProvisionException {
- try {
- IMetadataRepository repository = getManager().loadRepository(destinationLocation, IRepositoryManager.REPOSITORY_HINT_MODIFIABLE, null);
- if (repository != null && repository.isModifiable()) {
- if (destinationName != null)
- repository.setName(destinationName);
- if (!append)
- repository.removeAll();
- return repository;
- }
- } catch (ProvisionException e) {
- //fall through and create repo
- }
- //This code assumes source has been successfully loaded before this point
- //No existing repository; create a new repository at destinationLocation but with source's attributes.
- // TODO for now create a Simple repo by default.
- return (IMetadataRepository) RepositoryHelper.validDestinationRepository(getManager().createRepository(destinationLocation, destinationName == null ? source.getName() : destinationName, IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, source.getProperties()));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.equinox.app.IApplication#stop()
- */
- public void stop() {
- //do nothing
- }
-
- public void initializeFromArguments(String[] args) throws Exception {
- if (args == null)
- return;
- for (int i = 0; i < args.length; i++) {
- // check for args with parameters. If we are at the last argument or
- // if the next one has a '-' as the first character, then we can't have
- // an arg with a param so continue.
- if (i == args.length - 1 || args[i + 1].startsWith("-")) //$NON-NLS-1$
- continue;
- String arg = args[++i];
-
- if (args[i - 1].equalsIgnoreCase("-destinationName")) //$NON-NLS-1$
- destinationName = arg;
- if (args[i - 1].equalsIgnoreCase("-writeMode")) //$NON-NLS-1$
- if (args[i].equalsIgnoreCase("clean")) //$NON-NLS-1$
- append = false;
-
- try {
- if (args[i - 1].equalsIgnoreCase("-source")) //$NON-NLS-1$
- sourceLocation = RepositoryHelper.localRepoURIHelper(URIUtil.fromString(arg));
- if (args[i - 1].equalsIgnoreCase("-destination")) //$NON-NLS-1$
- destinationLocation = RepositoryHelper.localRepoURIHelper(URIUtil.fromString(arg));
- } catch (URISyntaxException e) {
- throw new IllegalArgumentException("Repository location (" + arg + ") must be a URL."); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (args[i - 1].equalsIgnoreCase("-roots")) //$NON-NLS-1$
- rootSpecs = getArrayArgsFromString(arg, ","); //$NON-NLS-1$
- if (args[i - 1].equalsIgnoreCase("-transitive")) //$NON-NLS-1$
- transitive = true;
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/Mirroring.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/Mirroring.java
deleted file mode 100644
index 4d9f965f8..000000000
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/Mirroring.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Code 9 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.metadata.mirror;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Query;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-
-/**
- * A utility class that performs mirroring of metadatas between repositories.
- */
-public class Mirroring {
-
- public void validate(IMetadataRepository source, IMetadataRepository destination) {
- if (source == null)
- throw new IllegalStateException("Source repository is null."); //$NON-NLS-1$
- if (destination == null)
- throw new IllegalStateException("Destination repository is null."); //$NON-NLS-1$
- if (!destination.isModifiable())
- throw new IllegalStateException("Destination repository must be modifiable: " + destination.getLocation()); //$NON-NLS-1$
- }
-
- public void mirror(IMetadataRepository source, IMetadataRepository destination, String[] rootSpecs, boolean transitive) {
- if (rootSpecs == null)
- mirror(source, destination, InstallableUnitQuery.ANY, transitive);
- else {
- VersionRangedName[] roots = new VersionRangedName[rootSpecs.length];
- for (int i = 0; i < rootSpecs.length; i++)
- roots[i] = VersionRangedName.parse(rootSpecs[i]);
- mirror(source, destination, new RangeQuery(roots), transitive);
- }
- }
-
- public void mirror(IMetadataRepository source, IMetadataRepository destination, Query query, boolean transitive) {
- validate(source, destination);
- Collector result = source.query(query, new Collector(), null);
- mirror(source, destination, (IInstallableUnit[]) result.toArray(IInstallableUnit.class), transitive);
- }
-
- private void mirror(IMetadataRepository source, IMetadataRepository destination, IInstallableUnit[] roots, boolean transitive) {
- if (transitive)
- roots = addTransitiveIUs(source, roots);
- destination.addInstallableUnits(roots);
- }
-
- protected IInstallableUnit[] addTransitiveIUs(IMetadataRepository source, IInstallableUnit[] roots) {
- // TODO Here we should create a profile from the source repo and discover all the
- // IUs that are needed to support the given roots. For now just assume that the
- // given roots are enough.
- return roots;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/RangeQuery.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/RangeQuery.java
deleted file mode 100644
index 5c2803f00..000000000
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/RangeQuery.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Code 9 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.metadata.mirror;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.MatchQuery;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-
-/**
- * A convenience query that will match any {@link IInstallableUnit}
- * it encounters.
- */
-public class RangeQuery extends MatchQuery {
- private VersionRangedName[] targets;
-
- /**
- * Creates a query that will match any {@link IInstallableUnit} with the given
- * VerionRangedName.
- *
- * @param targets The installable unit names with versions to match, or <code>null</code> to match any id
- */
- public RangeQuery(VersionRangedName[] targets) {
- this.targets = targets;
- }
-
- /**
- * Returns true if the <code>IInstallableUnit</code> object is contained in the <code>VerionRangedName</code>'s or targets is null.
- */
- public boolean isMatch(Object object) {
- if (!(object instanceof IInstallableUnit))
- return false;
- if (targets == null)
- return true;
- IInstallableUnit candidate = (IInstallableUnit) object;
- for (int i = 0; i < targets.length; i++) {
- VersionRangedName entry = targets[i];
- if (entry.getId().equalsIgnoreCase(candidate.getId()) && entry.getVersionRange().isIncluded(candidate.getVersion()))
- return true;
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/VersionRangedName.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/VersionRangedName.java
deleted file mode 100644
index 087fc9c2f..000000000
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/mirror/VersionRangedName.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Code 9 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Code 9 - initial API and implementation
- * IBM - ongoing development
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.metadata.mirror;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
-
-public class VersionRangedName {
- private final String id;
- private final VersionRange range;
-
- /**
- * Creates and returns a new version ranged id from the given spec. The spec should be
- * id/version range.
- * @param spec the spec for the version ranged id to create
- * @return the parsed versioned id
- */
- public static VersionRangedName parse(String spec) {
- String[] segments = MirrorApplication.getArrayArgsFromString(spec, "/"); //$NON-NLS-1$
- return new VersionRangedName(segments[0], segments.length == 1 ? null : segments[1]);
- }
-
- public VersionRangedName(String id, String rangeSpec) {
- this(id, new VersionRange(rangeSpec));
- }
-
- public VersionRangedName(String id, VersionRange range) {
- if (id == null)
- throw new IllegalArgumentException("id cannot be null"); //$NON-NLS-1$
- this.id = id;
- this.range = range != null ? range : new VersionRange(null);
- }
-
- public String getId() {
- return id;
- }
-
- public VersionRange getVersionRange() {
- return range;
- }
-
- public String toString() {
- return id + "/" + (range == null ? "0.0.0" : range.toString()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/Activator.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/Activator.java
index 0706b2556..59e004922 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/Activator.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/Activator.java
@@ -11,10 +11,8 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository;
-import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
-import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.osgi.framework.*;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
@@ -25,66 +23,48 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
public static final String REPO_PROVIDER_XPT = ID + '.' + "metadataRepositories"; //$NON-NLS-1$
private static BundleContext bundleContext;
- private static CacheManager cacheManager;
private ServiceRegistration repositoryManagerRegistration;
- private MetadataRepositoryManager repositoryManager;
- private ServiceTracker busTracker;
+ private ServiceTracker tracker;
public static BundleContext getContext() {
return bundleContext;
}
- public static CacheManager getCacheManager() {
- return cacheManager;
+ public Object addingService(ServiceReference reference) {
+ if (repositoryManagerRegistration == null) {
+ //TODO: eventually we shouldn't register a singleton manager automatically
+ IProvisioningAgent agent = (IProvisioningAgent) bundleContext.getService(reference);
+ IMetadataRepositoryManager manager = (MetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ repositoryManagerRegistration = bundleContext.registerService(IMetadataRepositoryManager.SERVICE_NAME, manager, null);
+ return agent;
+ }
+ return null;
}
- public void start(BundleContext context) throws Exception {
- //TODO eventually there should be no singleton repository manager registered
- Activator.bundleContext = context;
- cacheManager = new CacheManager((AgentLocation) ServiceHelper.getService(context, AgentLocation.SERVICE_NAME));
- repositoryManager = new MetadataRepositoryManager();
- repositoryManagerRegistration = context.registerService(IMetadataRepositoryManager.class.getName(), repositoryManager, null);
-
- // need to track event bus coming and going to make sure cache gets cleaned on repository removals
- busTracker = new ServiceTracker(context, IProvisioningEventBus.SERVICE_NAME, this);
- busTracker.open();
+ public void modifiedService(ServiceReference reference, Object service) {
+ // nothing to do
}
- public void stop(BundleContext context) throws Exception {
- IProvisioningEventBus bus = (IProvisioningEventBus) busTracker.getService();
- if (cacheManager != null) {
- cacheManager.unsetEventBus(bus);
- cacheManager = null;
- }
- Activator.bundleContext = null;
- if (repositoryManagerRegistration != null)
+ public void removedService(ServiceReference reference, Object service) {
+ if (repositoryManagerRegistration != null) {
repositoryManagerRegistration.unregister();
- repositoryManagerRegistration = null;
- if (repositoryManager != null) {
- repositoryManager.shutdown();
- repositoryManager = null;
+ repositoryManagerRegistration = null;
}
}
- public Object addingService(ServiceReference reference) {
- IProvisioningEventBus bus = (IProvisioningEventBus) bundleContext.getService(reference);
- if (repositoryManager != null)
- repositoryManager.setEventBus(bus);
- if (cacheManager != null)
- cacheManager.setEventBus(bus);
- return bus;
+ public void start(BundleContext aContext) throws Exception {
+ bundleContext = aContext;
+ //only want to register a service for the agent of the currently running system
+ String filter = "(&(objectClass=" + IProvisioningAgent.SERVICE_NAME + ")(agent.current=true))"; //$NON-NLS-1$ //$NON-NLS-2$
+ tracker = new ServiceTracker(aContext, aContext.createFilter(filter), this);
+ tracker.open();
}
- public void modifiedService(ServiceReference reference, Object service) {
- // ignored
-
- }
-
- public void removedService(ServiceReference reference, Object service) {
- final IProvisioningEventBus bus = (IProvisioningEventBus) service;
- if (repositoryManager != null)
- repositoryManager.unsetEventBus(bus);
- if (cacheManager != null)
- cacheManager.unsetEventBus(bus);
+ public void stop(BundleContext aContext) throws Exception {
+ if (tracker != null) {
+ tracker.close();
+ tracker = null;
+ }
+ bundleContext = null;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CacheManager.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CacheManager.java
index 24397e5e4..0e4eba8e5 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CacheManager.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CacheManager.java
@@ -11,21 +11,22 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository;
+import org.eclipse.equinox.p2.core.ProvisionException;
+
import java.io.*;
import java.net.URI;
-import java.net.URL;
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.ecf.filetransfer.UserCancelledException;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
-import org.eclipse.equinox.internal.p2.core.helpers.URLUtil;
import org.eclipse.equinox.internal.p2.repository.*;
import org.eclipse.equinox.internal.p2.repository.Activator;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.SynchronousProvisioningListener;
-import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation;
-import org.eclipse.equinox.internal.provisional.p2.repository.*;
+import org.eclipse.equinox.internal.provisional.p2.repository.IStateful;
+import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent;
+import org.eclipse.equinox.p2.core.IAgentLocation;
+import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.osgi.util.NLS;
/**
@@ -37,7 +38,12 @@ import org.eclipse.osgi.util.NLS;
* was created for the repository.
*/
public class CacheManager {
- private final AgentLocation agentLocation;
+ /**
+ * Service name for the internal cache manager service.
+ */
+ public static final String SERVICE_NAME = CacheManager.class.getName();
+
+ private final IAgentLocation agentLocation;
/**
* IStateful implementation of BufferedOutputStream. Class is used to get the status from
@@ -61,7 +67,7 @@ public class CacheManager {
}
- public CacheManager(AgentLocation agentLocation) {
+ public CacheManager(IAgentLocation agentLocation) {
this.agentLocation = agentLocation;
}
@@ -72,7 +78,7 @@ public class CacheManager {
private static final String RESUME_DEFAULT = "true"; //$NON-NLS-1$
private static final String XML_EXTENSION = ".xml"; //$NON-NLS-1$
- private final HashSet knownPrefixes = new HashSet(5);
+ private final HashSet<String> knownPrefixes = new HashSet<String>(5);
/**
* Returns a hash of the repository location.
@@ -211,8 +217,7 @@ public class CacheManager {
* @param repositoryLocation
*/
void deleteCache(URI repositoryLocation) {
- for (Iterator it = knownPrefixes.iterator(); it.hasNext();) {
- String prefix = (String) it.next();
+ for (String prefix : knownPrefixes) {
File[] cacheFiles = getCacheFiles(repositoryLocation, prefix);
for (int i = 0; i < cacheFiles.length; i++) {
// delete the cache file if it exists
@@ -241,8 +246,7 @@ public class CacheManager {
* Returns the file corresponding to the data area to be used by the cache manager.
*/
private File getCacheDirectory() {
- URL dataArea = agentLocation.getDataArea(Activator.ID + "/cache/"); //$NON-NLS-1$
- return URLUtil.toFile(dataArea);
+ return URIUtil.toFile(agentLocation.getDataArea(Activator.ID + "/cache/")); //$NON-NLS-1$
}
/**
@@ -264,7 +268,7 @@ public class CacheManager {
return RepositoryTransport.getInstance();
}
- public boolean isResumeEnabled() {
+ private boolean isResumeEnabled() {
String resumeProp = System.getProperty(PROP_RESUMABLE, RESUME_DEFAULT);
return Boolean.valueOf(resumeProp).booleanValue();
}
@@ -333,7 +337,7 @@ public class CacheManager {
* Adds a {@link SynchronousProvisioningListener} to the event bus for
* deleting cache files when the corresponding repository is deleted.
*/
- public void registerRepoEventListener(IProvisioningEventBus eventBus) {
+ private void registerRepoEventListener(IProvisioningEventBus eventBus) {
if (busListener == null) {
busListener = new SynchronousProvisioningListener() {
public void notify(EventObject o) {
@@ -372,7 +376,7 @@ public class CacheManager {
* Removes the {@link SynchronousProvisioningListener} that cleans up the
* cache file from the event bus.
*/
- public void unregisterRepoEventListener(IProvisioningEventBus bus) {
+ private void unregisterRepoEventListener(IProvisioningEventBus bus) {
if (bus != null && busListener != null)
bus.removeListener(busListener);
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java
index 0c57a1544..a627e566d 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java
@@ -19,20 +19,20 @@ import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
-import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.persistence.CompositeRepositoryIO;
import org.eclipse.equinox.internal.p2.persistence.CompositeRepositoryState;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.repository.ICompositeRepository;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
-import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.AbstractMetadataRepository;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.repository.ICompositeRepository;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository;
import org.eclipse.osgi.util.NLS;
-public class CompositeMetadataRepository extends AbstractMetadataRepository implements IMetadataRepository, ICompositeRepository {
+public class CompositeMetadataRepository extends AbstractMetadataRepository implements IMetadataRepository, ICompositeRepository<IInstallableUnit> {
static final public String REPOSITORY_TYPE = CompositeMetadataRepository.class.getName();
public static final String PI_REPOSITORY_TYPE = "compositeMetadataRepository"; //$NON-NLS-1$
@@ -42,27 +42,30 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
// keep a list of the child URIs. they can be absolute or relative. they may or may not point
// to a valid reachable repo
- private List childrenURIs = new ArrayList();
+ private List<URI> childrenURIs = new ArrayList<URI>();
// keep a list of the repositories that we have successfully loaded
- private List loadedRepos = new ArrayList();
+ private List<IMetadataRepository> loadedRepos = new ArrayList<IMetadataRepository>();
+ private IMetadataRepositoryManager manager;
/**
* Create a Composite repository in memory.
* @return the repository or null if unable to create one
*/
- public static CompositeMetadataRepository createMemoryComposite() {
- IMetadataRepositoryManager manager = getManager();
- if (manager == null)
+ public static CompositeMetadataRepository createMemoryComposite(IProvisioningAgent agent) {
+ if (agent == null)
+ return null;
+ IMetadataRepositoryManager repoManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ if (repoManager == null)
return null;
try {
//create a unique opaque URI
long time = System.currentTimeMillis();
URI repositoryURI = new URI("memory:" + String.valueOf(time)); //$NON-NLS-1$
- while (manager.contains(repositoryURI))
+ while (repoManager.contains(repositoryURI))
repositoryURI = new URI("memory:" + String.valueOf(++time)); //$NON-NLS-1$
- CompositeMetadataRepository result = (CompositeMetadataRepository) manager.createRepository(repositoryURI, repositoryURI.toString(), IMetadataRepositoryManager.TYPE_COMPOSITE_REPOSITORY, null);
- manager.removeRepository(repositoryURI);
+ CompositeMetadataRepository result = (CompositeMetadataRepository) repoManager.createRepository(repositoryURI, repositoryURI.toString(), IMetadataRepositoryManager.TYPE_COMPOSITE_REPOSITORY, null);
+ repoManager.removeRepository(repositoryURI);
return result;
} catch (ProvisionException e) {
// just return null
@@ -73,8 +76,8 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
return null;
}
- static private IMetadataRepositoryManager getManager() {
- return (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
+ private IMetadataRepositoryManager getManager() {
+ return manager;
}
private boolean isLocal() {
@@ -85,8 +88,9 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
return isLocal();
}
- public CompositeMetadataRepository(URI location, String name, Map properties) {
+ CompositeMetadataRepository(IMetadataRepositoryManager manager, URI location, String name, Map<String, String> properties) {
super(name == null ? (location != null ? location.toString() : "") : name, REPOSITORY_TYPE, REPOSITORY_VERSION.toString(), location, null, null, properties); //$NON-NLS-1$
+ this.manager = manager;
//when creating a repository, we must ensure it exists on disk so a subsequent load will succeed
save();
}
@@ -94,8 +98,9 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
/*
* This is only called by the parser when loading a repository.
*/
- public CompositeMetadataRepository(CompositeRepositoryState state) {
+ CompositeMetadataRepository(IMetadataRepositoryManager manager, CompositeRepositoryState state) {
super(state.getName(), state.getType(), state.getVersion(), state.getLocation(), state.getDescription(), state.getProvider(), state.getProperties());
+ this.manager = manager;
for (int i = 0; i < state.getChildren().length; i++)
addChild(state.getChildren()[i], false);
}
@@ -114,22 +119,21 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
result.setProvider(getProvider());
result.setProperties(getProperties());
// it is important to directly access the field so we have the relative URIs
- result.setChildren((URI[]) childrenURIs.toArray(new URI[childrenURIs.size()]));
+ result.setChildren(childrenURIs.toArray(new URI[childrenURIs.size()]));
return result;
}
- public Collector query(Query query, Collector collector, IProgressMonitor monitor) {
+ public IQueryResult<IInstallableUnit> query(IQuery<IInstallableUnit> query, IProgressMonitor monitor) {
if (monitor == null)
monitor = new NullProgressMonitor();
try {
// Query all the all the repositories this composite repo contains
- CompoundQueryable queryable = new CompoundQueryable((IQueryable[]) loadedRepos.toArray(new IQueryable[loadedRepos.size()]));
- collector = queryable.query(query, collector, monitor);
+ CompoundQueryable<IInstallableUnit> queryable = new CompoundQueryable<IInstallableUnit>(loadedRepos);
+ return queryable.query(query, monitor);
} finally {
if (monitor != null)
monitor.done();
}
- return collector;
}
private void addChild(URI childURI, boolean save) {
@@ -172,13 +176,12 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
if (removed) {
// we removed the child from the list so remove the associated repo object as well
IMetadataRepository found = null;
- for (Iterator iter = loadedRepos.iterator(); found == null && iter.hasNext();) {
- IMetadataRepository current = (IMetadataRepository) iter.next();
+ for (IMetadataRepository current : loadedRepos) {
URI repoLocation = current.getLocation();
- if (URIUtil.sameURI(childURI, repoLocation))
- found = current;
- else if (URIUtil.sameURI(other, repoLocation))
+ if (URIUtil.sameURI(childURI, repoLocation) || URIUtil.sameURI(other, repoLocation)) {
found = current;
+ break;
+ }
}
if (found != null)
loadedRepos.remove(found);
@@ -200,7 +203,7 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
throw new UnsupportedOperationException("Cannot remove IUs to a composite repository");
}
- public synchronized boolean removeInstallableUnits(Query query, IProgressMonitor monitor) {
+ public synchronized boolean removeInstallableUnits(IInstallableUnit[] installableUnits, IProgressMonitor monitor) {
throw new UnsupportedOperationException("Cannot remove IUs to a composite repository");
}
@@ -233,7 +236,7 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
return;
File file = getActualLocation(location);
File jarFile = getActualLocation(location, JAR_EXTENSION);
- boolean compress = "true".equalsIgnoreCase((String) properties.get(PROP_COMPRESSED)); //$NON-NLS-1$
+ boolean compress = "true".equalsIgnoreCase(properties.get(PROP_COMPRESSED)); //$NON-NLS-1$
try {
OutputStream output = null;
if (!compress) {
@@ -267,10 +270,10 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
}
}
- public List getChildren() {
- List result = new ArrayList();
- for (Iterator iter = childrenURIs.iterator(); iter.hasNext();)
- result.add(URIUtil.makeAbsolute((URI) iter.next(), location));
+ public List<URI> getChildren() {
+ List<URI> result = new ArrayList<URI>();
+ for (URI childURI : childrenURIs)
+ result.add(URIUtil.makeAbsolute(childURI, location));
return result;
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepositoryFactory.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepositoryFactory.java
index c2560bbc3..74792b07d 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepositoryFactory.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepositoryFactory.java
@@ -10,6 +10,10 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository;
+import org.eclipse.equinox.p2.repository.metadata.spi.MetadataRepositoryFactory;
+
+import org.eclipse.equinox.p2.core.ProvisionException;
+
import java.io.*;
import java.net.URI;
import java.util.Map;
@@ -19,10 +23,9 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.Tracing;
import org.eclipse.equinox.internal.p2.persistence.CompositeRepositoryIO;
import org.eclipse.equinox.internal.p2.persistence.CompositeRepositoryState;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
-import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.MetadataRepositoryFactory;
+import org.eclipse.equinox.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.osgi.util.NLS;
public class CompositeMetadataRepositoryFactory extends MetadataRepositoryFactory {
@@ -32,8 +35,14 @@ public class CompositeMetadataRepositoryFactory extends MetadataRepositoryFactor
private static final String PROTOCOL_FILE = "file"; //$NON-NLS-1$
public static final String CONTENT_FILENAME = "compositeContent"; //$NON-NLS-1$
- public IMetadataRepository create(URI location, String name, String type, Map properties) {
- return new CompositeMetadataRepository(location, name, properties);
+ public IMetadataRepository create(URI location, String name, String type, Map<String, String> properties) {
+ return new CompositeMetadataRepository(getManager(), location, name, properties);
+ }
+
+ private IMetadataRepositoryManager getManager() {
+ if (getAgent() != null)
+ return (IMetadataRepositoryManager) getAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);
+ return null;
}
/**
@@ -58,7 +67,10 @@ public class CompositeMetadataRepositoryFactory extends MetadataRepositoryFactor
throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_NOT_FOUND, msg, null));
}
//file is not local, create a cache of the repository metadata
- localFile = Activator.getCacheManager().createCache(location, CONTENT_FILENAME, monitor);
+ CacheManager cache = (CacheManager) getAgent().getService(CacheManager.SERVICE_NAME);
+ if (cache == null)
+ throw new IllegalArgumentException("Cache manager service not available"); //$NON-NLS-1$
+ localFile = cache.createCache(location, CONTENT_FILENAME, monitor);
if (localFile == null) {
//there is no remote file in either form
String msg = NLS.bind(Messages.io_failedRead, location);
@@ -69,7 +81,7 @@ public class CompositeMetadataRepositoryFactory extends MetadataRepositoryFactor
/*
* (non-Javadoc)
- * @see org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.MetadataRepositoryFactory#validate(java.net.URL, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.equinox.p2.repository.metadata.spi.MetadataRepositoryFactory#validate(java.net.URL, org.eclipse.core.runtime.IProgressMonitor)
*/
public IStatus validate(URI location, IProgressMonitor monitor) {
try {
@@ -81,7 +93,7 @@ public class CompositeMetadataRepositoryFactory extends MetadataRepositoryFactor
}
/* (non-Javadoc)
- * @see org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.MetadataRepositoryFactory#load(java.net.URL, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.equinox.p2.repository.metadata.spi.MetadataRepositoryFactory#load(java.net.URL, org.eclipse.core.runtime.IProgressMonitor)
*/
public IMetadataRepository load(URI location, int flags, IProgressMonitor monitor) throws ProvisionException {
return validateAndLoad(location, true, flags, monitor);
@@ -124,7 +136,7 @@ public class CompositeMetadataRepositoryFactory extends MetadataRepositoryFactor
CompositeRepositoryState resultState = io.read(localFile.toURL(), descriptorStream, CompositeMetadataRepository.PI_REPOSITORY_TYPE, sub.newChild(100));
if (resultState.getLocation() == null)
resultState.setLocation(location);
- CompositeMetadataRepository result = new CompositeMetadataRepository(resultState);
+ CompositeMetadataRepository result = new CompositeMetadataRepository(getManager(), resultState);
if (Tracing.DEBUG_METADATA_PARSING) {
time += System.currentTimeMillis();
Tracing.debug(debugMsg + "time (ms): " + time); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/IUMap.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/IUMap.java
new file mode 100644
index 000000000..ba8adab1d
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/IUMap.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.metadata.repository;
+
+import java.util.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.Collector;
+import org.eclipse.equinox.p2.query.IQueryResult;
+
+/**
+ * A map that stores {@link IInstallableUnit} instances in a way that is efficient to query
+ */
+public class IUMap {
+ /**
+ * Iterator over all the {@link IInstallableUnit} instances in the map.
+ */
+ public class MapIterator implements Iterator<IInstallableUnit> {
+ //iterator over the keys in UIMap
+ private Iterator<String> unitIterator;
+ //iterator over the Set inside a single value of the IUMap
+ private Iterator<IInstallableUnit> currentBucket;
+
+ MapIterator() {
+ super();
+ unitIterator = units.keySet().iterator();
+ }
+
+ public boolean hasNext() {
+ return unitIterator.hasNext() || (currentBucket != null && currentBucket.hasNext());
+ }
+
+ public IInstallableUnit next() {
+ if (currentBucket == null || !currentBucket.hasNext())
+ currentBucket = units.get(unitIterator.next()).iterator();
+ return currentBucket.next();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ /**
+ * Map<String,Set<IInstallableUnit>> mapping IU id to iu's with that id.
+ */
+ final Map<String, Set<IInstallableUnit>> units = new HashMap<String, Set<IInstallableUnit>>();
+
+ public void add(IInstallableUnit unit) {
+ Set<IInstallableUnit> matching = units.get(unit.getId());
+ if (matching == null) {
+ matching = new HashSet<IInstallableUnit>(2);
+ units.put(unit.getId(), matching);
+ }
+ matching.add(unit);
+ }
+
+ public void addAll(IInstallableUnit[] toAdd) {
+ for (int i = 0; i < toAdd.length; i++)
+ add(toAdd[i]);
+ }
+
+ public void clear() {
+ units.clear();
+ }
+
+ public Iterator<IInstallableUnit> iterator() {
+ return new MapIterator();
+ }
+
+ public IQueryResult<IInstallableUnit> query(InstallableUnitQuery query) {
+ //iterate over the entire map, or just the IU's with the given id
+ Iterator<IInstallableUnit> candidates;
+ if (query.getId() == null)
+ candidates = iterator();
+ else {
+ Collection<IInstallableUnit> bucket = units.get(query.getId());
+ if (bucket == null)
+ return Collector.emptyCollector();
+ candidates = bucket.iterator();
+ }
+ return query.perform(candidates);
+
+ }
+
+ public void remove(IInstallableUnit unit) {
+ Set<IInstallableUnit> matching = units.get(unit.getId());
+ if (matching == null)
+ return;
+ matching.remove(unit);
+ if (matching.isEmpty())
+ units.remove(unit.getId());
+ }
+
+ public void removeAll(Collection<IInstallableUnit> toRemove) {
+ for (IInstallableUnit iu : toRemove)
+ remove(iu);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java
index a85a4e612..709c7357f 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java
@@ -11,27 +11,24 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Query;
-
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
-import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent;
-
import java.io.*;
import java.net.URI;
import java.util.*;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
-import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.internal.p2.core.helpers.*;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.AbstractMetadataRepository;
-import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.RepositoryReference;
+import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.IQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository;
+import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
/**
* A metadata repository that resides in the local file system. If the repository
@@ -46,8 +43,8 @@ public class LocalMetadataRepository extends AbstractMetadataRepository {
static final private String JAR_EXTENSION = ".jar"; //$NON-NLS-1$
static final private String XML_EXTENSION = ".xml"; //$NON-NLS-1$
- protected HashSet units = new LinkedHashSet();
- protected HashSet repositories = new HashSet();
+ protected IUMap units = new IUMap();
+ protected HashSet<RepositoryReference> repositories = new HashSet<RepositoryReference>();
private static File getActualLocation(URI location, String extension) {
File spec = URIUtil.toFile(location);
@@ -80,7 +77,7 @@ public class LocalMetadataRepository extends AbstractMetadataRepository {
* @param location The location of the repository
* @param name The name of the repository
*/
- public LocalMetadataRepository(URI location, String name, Map properties) {
+ public LocalMetadataRepository(URI location, String name, Map<String, String> properties) {
super(name == null ? (location != null ? location.toString() : "") : name, REPOSITORY_TYPE, REPOSITORY_VERSION.toString(), location, null, null, properties); //$NON-NLS-1$
if (!location.getScheme().equals("file")) //$NON-NLS-1$
throw new IllegalArgumentException("Invalid local repository location: " + location); //$NON-NLS-1$
@@ -91,7 +88,7 @@ public class LocalMetadataRepository extends AbstractMetadataRepository {
public synchronized void addInstallableUnits(IInstallableUnit[] installableUnits) {
if (installableUnits == null || installableUnits.length == 0)
return;
- units.addAll(Arrays.asList(installableUnits));
+ units.addAll(installableUnits);
save();
}
@@ -109,7 +106,7 @@ public class LocalMetadataRepository extends AbstractMetadataRepository {
this.description = state.Description;
this.location = state.Location;
this.properties = state.Properties;
- this.units.addAll(Arrays.asList(state.Units));
+ this.units.addAll(state.Units);
this.repositories.addAll(Arrays.asList(state.Repositories));
}
publishRepositoryReferences();
@@ -123,18 +120,17 @@ public class LocalMetadataRepository extends AbstractMetadataRepository {
if (bus == null)
return;
- List repositoriesSnapshot = createRepositoriesSnapshot();
- for (Iterator it = repositoriesSnapshot.iterator(); it.hasNext();) {
- RepositoryReference reference = (RepositoryReference) it.next();
+ List<RepositoryReference> repositoriesSnapshot = createRepositoriesSnapshot();
+ for (RepositoryReference reference : repositoriesSnapshot) {
boolean isEnabled = (reference.Options & IRepository.ENABLED) != 0;
bus.publishEvent(new RepositoryEvent(reference.Location, reference.Type, RepositoryEvent.DISCOVERED, isEnabled));
}
}
- private synchronized List createRepositoriesSnapshot() {
+ private synchronized List<RepositoryReference> createRepositoriesSnapshot() {
if (repositories.isEmpty())
- return Collections.EMPTY_LIST;
- return new ArrayList(repositories);
+ return CollectionUtils.emptyList();
+ return new ArrayList<RepositoryReference>(repositories);
}
// use this method to setup any transient fields etc after the object has been restored from a stream
@@ -146,8 +142,10 @@ public class LocalMetadataRepository extends AbstractMetadataRepository {
return true;
}
- public synchronized Collector query(Query query, Collector collector, IProgressMonitor monitor) {
- return query.perform(units.iterator(), collector);
+ public synchronized IQueryResult<IInstallableUnit> query(IQuery<IInstallableUnit> query, IProgressMonitor monitor) {
+ if (query instanceof InstallableUnitQuery)
+ return units.query((InstallableUnitQuery) query);
+ return query.perform(units.iterator());
}
public synchronized void removeAll() {
@@ -155,12 +153,11 @@ public class LocalMetadataRepository extends AbstractMetadataRepository {
save();
}
- public synchronized boolean removeInstallableUnits(Query query, IProgressMonitor monitor) {
+ public synchronized boolean removeInstallableUnits(IInstallableUnit[] installableUnits, IProgressMonitor monitor) {
boolean changed = false;
- Collector results = query.perform(units.iterator(), new Collector());
- if (results.size() > 0) {
+ if (installableUnits != null && installableUnits.length > 0) {
changed = true;
- units.removeAll(results.toCollection());
+ units.removeAll(Arrays.asList(installableUnits));
}
if (changed)
save();
@@ -171,7 +168,7 @@ public class LocalMetadataRepository extends AbstractMetadataRepository {
private void save() {
File file = getActualLocation(location);
File jarFile = getActualLocation(location, JAR_EXTENSION);
- boolean compress = "true".equalsIgnoreCase((String) properties.get(PROP_COMPRESSED)); //$NON-NLS-1$
+ boolean compress = "true".equalsIgnoreCase(properties.get(PROP_COMPRESSED)); //$NON-NLS-1$
try {
OutputStream output = null;
if (!compress) {
@@ -214,7 +211,7 @@ public class LocalMetadataRepository extends AbstractMetadataRepository {
save();
}
//force repository manager to reload this repository because it caches properties
- MetadataRepositoryManager manager = (MetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
+ MetadataRepositoryManager manager = (MetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
if (manager.removeRepository(getLocation()))
manager.addRepository(this);
return oldValue;
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryComponent.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryComponent.java
index 9474158c8..822be6365 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryComponent.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryComponent.java
@@ -11,10 +11,10 @@
package org.eclipse.equinox.internal.p2.metadata.repository;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
-import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.core.IAgentLocation;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
/**
* Service factory for creating {@link IMetadataRepositoryManager} instances.
@@ -25,8 +25,11 @@ public class MetadataRepositoryComponent implements IAgentServiceFactory {
MetadataRepositoryManager manager = new MetadataRepositoryManager();
final IProvisioningEventBus eventBus = (IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME);
manager.setEventBus(eventBus);
- CacheManager cache = new CacheManager((AgentLocation) agent.getService(AgentLocation.SERVICE_NAME));
+ manager.setAgentLocation((IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME));
+ manager.setAgent(agent);
+ CacheManager cache = new CacheManager((IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME));
cache.setEventBus(eventBus);
+ agent.registerService(CacheManager.SERVICE_NAME, cache);
return manager;
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java
index dbc5b1ccc..4de5b12e0 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java
@@ -11,10 +11,8 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
import java.io.*;
import java.net.MalformedURLException;
@@ -28,13 +26,13 @@ import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataParser;
import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataWriter;
import org.eclipse.equinox.internal.p2.persistence.XMLWriter;
-import org.eclipse.equinox.internal.provisional.p2.core.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.AbstractMetadataRepository;
-import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.RepositoryReference;
-import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.AbstractMetadataRepository.RepositoryState;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository.RepositoryState;
+import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleContext;
import org.xml.sax.*;
@@ -99,9 +97,9 @@ public class MetadataRepositoryIO {
// Constants defining the structure of the XML for a MetadataRepository
// A format version number for metadata repository XML.
- public static final Version COMPATIBLE_VERSION = new Version(1, 0, 0);
- public static final Version CURRENT_VERSION = new Version(1, 1, 0);
- public static final VersionRange XML_TOLERANCE = new VersionRange(COMPATIBLE_VERSION, true, new Version(2, 0, 0), false);
+ public static final Version COMPATIBLE_VERSION = Version.createOSGi(1, 0, 0);
+ public static final Version CURRENT_VERSION = Version.createOSGi(1, 1, 0);
+ public static final VersionRange XML_TOLERANCE = new VersionRange(COMPATIBLE_VERSION, true, Version.createOSGi(2, 0, 0), false);
// Constants for processing Instructions
public static final String PI_REPOSITORY_TARGET = "metadataRepository"; //$NON-NLS-1$
@@ -111,7 +109,7 @@ public class MetadataRepositoryIO {
}
- protected XMLWriter.ProcessingInstruction[] createPI(Class repositoryClass) {
+ protected XMLWriter.ProcessingInstruction[] createPI(Class<?> repositoryClass) {
//TODO We should remove this processing instruction, but currently old clients rely on this. See bug 210450.
return new XMLWriter.ProcessingInstruction[] {XMLWriter.ProcessingInstruction.makeTargetVersionInstruction(XMLConstants.PI_REPOSITORY_TARGET, XMLConstants.CURRENT_VERSION)};
}
@@ -119,7 +117,7 @@ public class MetadataRepositoryIO {
// XML writer for a IMetadataRepository
protected class Writer extends MetadataWriter implements XMLConstants {
- public Writer(OutputStream output, Class repositoryClass) throws IOException {
+ public Writer(OutputStream output, Class<? extends IMetadataRepository> repositoryClass) throws IOException {
super(output, createPI(repositoryClass));
}
@@ -135,11 +133,12 @@ public class MetadataRepositoryIO {
attributeOptional(DESCRIPTION_ATTRIBUTE, repository.getDescription()); // TODO: could be cdata?
writeProperties(repository.getProperties());
- Collector units = repository.query(InstallableUnitQuery.ANY, new Collector(), null);
if (repository instanceof LocalMetadataRepository) {
- Set references = ((LocalMetadataRepository) repository).repositories;
+ Set<RepositoryReference> references = ((LocalMetadataRepository) repository).repositories;
writeRepositoryReferences(references.iterator(), references.size());
}
+ // The size attribute is a problematic since it forces the use of a collection.
+ Set<IInstallableUnit> units = repository.query(InstallableUnitQuery.ANY, null).unmodifiableSet();
writeInstallableUnits(units.iterator(), units.size());
end(REPOSITORY_ELEMENT);
@@ -151,13 +150,13 @@ public class MetadataRepositoryIO {
* @param references An Iterator of {@link RepositoryReference}.
* @param size The number of references to write
*/
- protected void writeRepositoryReferences(Iterator references, int size) {
+ protected void writeRepositoryReferences(Iterator<RepositoryReference> references, int size) {
if (size == 0)
return;
start(REPOSITORY_REFERENCES_ELEMENT);
attribute(COLLECTION_SIZE_ATTRIBUTE, size);
while (references.hasNext())
- writeRepositoryReference((RepositoryReference) references.next());
+ writeRepositoryReference(references.next());
end(REPOSITORY_REFERENCES_ELEMENT);
}
@@ -309,7 +308,7 @@ public class MetadataRepositoryIO {
//can't create repository if missing type - this is already logged when parsing attributes
if (state.Type == null)
return;
- Class clazz = Class.forName(state.Type);
+ Class<?> clazz = Class.forName(state.Type);
Object repositoryObject = clazz.newInstance();
if (repositoryObject instanceof AbstractMetadataRepository) {
repository = (AbstractMetadataRepository) repositoryObject;
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java
index 35573be3c..315dc6f38 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryManager.java
@@ -11,22 +11,24 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository;
+import org.eclipse.equinox.p2.repository.metadata.spi.MetadataRepositoryFactory;
+
+import org.eclipse.equinox.p2.core.ProvisionException;
+
import java.net.URI;
-import java.util.*;
+import java.util.Map;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
-import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.MetadataRepositoryFactory;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.osgi.util.NLS;
/**
* Default implementation of {@link IMetadataRepositoryManager}.
*/
-public class MetadataRepositoryManager extends AbstractRepositoryManager implements IMetadataRepositoryManager {
+public class MetadataRepositoryManager extends AbstractRepositoryManager<IInstallableUnit> implements IMetadataRepositoryManager {
public MetadataRepositoryManager() {
super();
@@ -36,21 +38,23 @@ public class MetadataRepositoryManager extends AbstractRepositoryManager impleme
super.addRepository(repository, true, null);
}
- public IMetadataRepository createRepository(URI location, String name, String type, Map properties) throws ProvisionException {
+ public IMetadataRepository createRepository(URI location, String name, String type, Map<String, String> properties) throws ProvisionException {
return (IMetadataRepository) doCreateRepository(location, name, type, properties);
}
- protected IRepository factoryCreate(URI location, String name, String type, Map properties, IExtension extension) throws ProvisionException {
+ protected IRepository<IInstallableUnit> factoryCreate(URI location, String name, String type, Map<String, String> properties, IExtension extension) throws ProvisionException {
MetadataRepositoryFactory factory = (MetadataRepositoryFactory) createExecutableExtension(extension, EL_FACTORY);
if (factory == null)
return null;
+ factory.setAgent(agent);
return factory.create(location, name, type, properties);
}
- protected IRepository factoryLoad(URI location, IExtension extension, int flags, SubMonitor monitor) throws ProvisionException {
+ protected IRepository<IInstallableUnit> factoryLoad(URI location, IExtension extension, int flags, SubMonitor monitor) throws ProvisionException {
MetadataRepositoryFactory factory = (MetadataRepositoryFactory) createExecutableExtension(extension, EL_FACTORY);
if (factory == null)
return null;
+ factory.setAgent(agent);
return factory.load(location, flags, monitor.newChild(10));
}
@@ -81,9 +85,6 @@ public class MetadataRepositoryManager extends AbstractRepositoryManager impleme
return IRepository.TYPE_METADATA;
}
- /**
- * @deprecated see {@link #loadRepository(URI, int, IProgressMonitor)}
- */
public IMetadataRepository loadRepository(URI location, IProgressMonitor monitor) throws ProvisionException {
return loadRepository(location, 0, monitor);
}
@@ -92,49 +93,6 @@ public class MetadataRepositoryManager extends AbstractRepositoryManager impleme
return (IMetadataRepository) loadRepository(location, monitor, null, flags);
}
- /**
- * Performs a query against all of the installable units of each known
- * repository, accumulating any objects that satisfy the query in the
- * provided collector.
- * <p>
- * Note that using this method can be quite expensive, as every known
- * metadata repository will be loaded in order to query each one. If a
- * client wishes to query only certain repositories, it is better to use
- * {@link #getKnownRepositories(int)} to filter the list of repositories
- * loaded and then query each of the returned repositories.
- * <p>
- * This method is long-running; progress and cancellation are provided
- * by the given progress monitor.
- *
- * @param query The query to perform against each installable unit in each known repository
- * @param collector Collects the results of the query
- * @param monitor a progress monitor, or <code>null</code> if progress
- * reporting is not desired
- * @return The collector argument
- */
- public Collector query(Query query, Collector collector, IProgressMonitor monitor) {
- URI[] locations = getKnownRepositories(REPOSITORIES_ALL);
- List queryables = new ArrayList(locations.length); // use a list since we don't know exactly how many will load
- SubMonitor sub = SubMonitor.convert(monitor, locations.length * 10);
- for (int i = 0; i < locations.length; i++) {
- try {
- if (sub.isCanceled())
- throw new OperationCanceledException();
- queryables.add(loadRepository(locations[i], sub.newChild(9)));
- } catch (ProvisionException e) {
- //ignore this repository for this query
- }
- }
- try {
- IQueryable[] queryablesArray = (IQueryable[]) queryables.toArray(new IQueryable[queryables.size()]);
- CompoundQueryable compoundQueryable = new CompoundQueryable(queryablesArray);
- compoundQueryable.query(query, collector, sub.newChild(locations.length * 1));
- } finally {
- sub.done();
- }
- return collector;
- }
-
public IMetadataRepository refreshRepository(URI location, IProgressMonitor monitor) throws ProvisionException {
return (IMetadataRepository) basicRefreshRepository(location, monitor);
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/metadata/repository/SimpleMetadataRepositoryFactory.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/SimpleMetadataRepositoryFactory.java
index 012c44d1f..9da7a8c06 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/metadata/repository/SimpleMetadataRepositoryFactory.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/SimpleMetadataRepositoryFactory.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository;
+package org.eclipse.equinox.internal.p2.metadata.repository;
import java.io.*;
import java.net.URI;
@@ -17,10 +17,10 @@ import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.Tracing;
-import org.eclipse.equinox.internal.p2.metadata.repository.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.spi.MetadataRepositoryFactory;
import org.eclipse.osgi.util.NLS;
public class SimpleMetadataRepositoryFactory extends MetadataRepositoryFactory {
@@ -29,7 +29,7 @@ public class SimpleMetadataRepositoryFactory extends MetadataRepositoryFactory {
private static final String XML_EXTENSION = ".xml"; //$NON-NLS-1$
private static final String PROTOCOL_FILE = "file"; //$NON-NLS-1$
- public IMetadataRepository create(URI location, String name, String type, Map properties) {
+ public IMetadataRepository create(URI location, String name, String type, Map<String, String> properties) {
if (location.getScheme().equals("file")) //$NON-NLS-1$
return new LocalMetadataRepository(location, name, properties);
return new URLMetadataRepository(location, name, properties);
@@ -57,7 +57,10 @@ public class SimpleMetadataRepositoryFactory extends MetadataRepositoryFactory {
throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_NOT_FOUND, msg, null));
}
// file is not local, create a cache of the repository metadata
- localFile = Activator.getCacheManager().createCache(location, URLMetadataRepository.CONTENT_FILENAME, monitor);
+ CacheManager cache = (CacheManager) getAgent().getService(CacheManager.SERVICE_NAME);
+ if (cache == null)
+ throw new IllegalArgumentException("Cache manager service not available"); //$NON-NLS-1$
+ localFile = cache.createCache(location, URLMetadataRepository.CONTENT_FILENAME, monitor);
if (localFile == null) {
// there is no remote file in either form - this should not really happen as
// createCache should bail out with exception if something is wrong. This is an internal
@@ -69,7 +72,7 @@ public class SimpleMetadataRepositoryFactory extends MetadataRepositoryFactory {
/*
* (non-Javadoc)
- * @see org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.MetadataRepositoryFactory#validate(java.net.URL, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.equinox.p2.repository.metadata.spi.MetadataRepositoryFactory#validate(java.net.URL, org.eclipse.core.runtime.IProgressMonitor)
*/
public IStatus validate(URI location, IProgressMonitor monitor) {
try {
@@ -81,7 +84,7 @@ public class SimpleMetadataRepositoryFactory extends MetadataRepositoryFactory {
}
/* (non-Javadoc)
- * @see org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.MetadataRepositoryFactory#load(java.net.URL, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.equinox.p2.repository.metadata.spi.MetadataRepositoryFactory#load(java.net.URL, org.eclipse.core.runtime.IProgressMonitor)
*/
public IMetadataRepository load(URI location, int flags, IProgressMonitor monitor) throws ProvisionException {
return validateAndLoad(location, true, flags, monitor);
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/URLMetadataRepository.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/URLMetadataRepository.java
index a80a20a33..287be742b 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/URLMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/URLMetadataRepository.java
@@ -11,15 +11,15 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Query;
-
import java.net.URI;
-import java.util.*;
+import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.URIUtil;
-import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.AbstractMetadataRepository;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.IQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository;
/**
* A metadata repository backed by an arbitrary URL.
@@ -32,7 +32,7 @@ public class URLMetadataRepository extends AbstractMetadataRepository {
private static final Integer REPOSITORY_VERSION = new Integer(1);
transient protected URI content;
- protected HashSet units = new LinkedHashSet();
+ protected IUMap units = new IUMap();
public static URI getActualLocation(URI base) {
return getActualLocation(base, XML_EXTENSION);
@@ -48,7 +48,7 @@ public class URLMetadataRepository extends AbstractMetadataRepository {
super();
}
- public URLMetadataRepository(URI location, String name, Map properties) {
+ public URLMetadataRepository(URI location, String name, Map<String, String> properties) {
super(name == null ? (location != null ? location.toString() : "") : name, REPOSITORY_TYPE, REPOSITORY_VERSION.toString(), location, null, null, properties); //$NON-NLS-1$
content = getActualLocation(location);
}
@@ -66,7 +66,7 @@ public class URLMetadataRepository extends AbstractMetadataRepository {
this.description = state.Description;
this.location = state.Location;
this.properties = state.Properties;
- this.units.addAll(Arrays.asList(state.Units));
+ this.units.addAll(state.Units);
}
// Use this method to setup any transient fields etc after the object has been restored from a stream
@@ -79,7 +79,9 @@ public class URLMetadataRepository extends AbstractMetadataRepository {
return false;
}
- public synchronized Collector query(Query query, Collector collector, IProgressMonitor monitor) {
- return query.perform(units.iterator(), collector);
+ public synchronized IQueryResult<IInstallableUnit> query(IQuery<IInstallableUnit> query, IProgressMonitor monitor) {
+ if (query instanceof InstallableUnitQuery)
+ return units.query((InstallableUnitQuery) query);
+ return query.perform(units.iterator());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java
index d79b4df5d..e9eed98a8 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java
@@ -12,34 +12,47 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository.io;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
-
import java.net.URI;
import java.util.*;
+import java.util.Map.Entry;
import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.internal.p2.persistence.XMLParser;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.*;
-import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.RepositoryReference;
+import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
+import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
public abstract class MetadataParser extends XMLParser implements XMLConstants {
+ static final ILicense[] NO_LICENSES = new ILicense[0];
public MetadataParser(BundleContext context, String bundleId) {
super(context, bundleId);
}
- protected class RepositoryReferencesHandler extends AbstractHandler {
- private HashSet references;
+ protected abstract class AbstractMetadataHandler extends AbstractHandler {
+
+ public AbstractMetadataHandler(ContentHandler parentHandler, String elementHandled) {
+ super(parentHandler, elementHandled);
+ }
+
+ int getOptionalSize(Attributes attributes, int dflt) {
+ String sizeStr = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE);
+ return sizeStr != null ? Integer.parseInt(sizeStr) : dflt;
+ }
+ }
+
+ protected class RepositoryReferencesHandler extends AbstractMetadataHandler {
+ private HashSet<RepositoryReference> references;
public RepositoryReferencesHandler(AbstractHandler parentHandler, Attributes attributes) {
super(parentHandler, REPOSITORY_REFERENCES_ELEMENT);
- String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE);
- references = (size != null ? new HashSet(Integer.parseInt(size)) : new HashSet(4));
+ references = new HashSet<RepositoryReference>(getOptionalSize(attributes, 4));
}
public void startElement(String name, Attributes attributes) {
@@ -51,7 +64,7 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
public RepositoryReference[] getReferences() {
- return (RepositoryReference[]) references.toArray(new RepositoryReference[references.size()]);
+ return references.toArray(new RepositoryReference[references.size()]);
}
}
@@ -59,7 +72,7 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
private final String[] required = new String[] {TYPE_ATTRIBUTE, OPTIONS_ATTRIBUTE};
- public RepositoryReferenceHandler(AbstractHandler parentHandler, Attributes attributes, Set references) {
+ public RepositoryReferenceHandler(AbstractHandler parentHandler, Attributes attributes, Set<RepositoryReference> references) {
super(parentHandler, REPOSITORY_REFERENCE_ELEMENT);
String[] values = parseRequiredAttributes(attributes, required);
String name = parseOptionalAttribute(attributes, NAME_ATTRIBUTE);
@@ -75,23 +88,20 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
}
- protected class InstallableUnitsHandler extends AbstractHandler {
- private ArrayList units;
+ protected class InstallableUnitsHandler extends AbstractMetadataHandler {
+ private ArrayList<InstallableUnitDescription> units;
public InstallableUnitsHandler(AbstractHandler parentHandler, Attributes attributes) {
super(parentHandler, INSTALLABLE_UNITS_ELEMENT);
- String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE);
- units = (size != null ? new ArrayList(new Integer(size).intValue()) : new ArrayList(4));
+ units = new ArrayList<InstallableUnitDescription>(getOptionalSize(attributes, 4));
}
public IInstallableUnit[] getUnits() {
int size = units.size();
IInstallableUnit[] result = new IInstallableUnit[size];
int i = 0;
- for (Iterator it = units.iterator(); it.hasNext(); i++) {
- InstallableUnitDescription desc = (InstallableUnitDescription) it.next();
- result[i] = MetadataFactory.createInstallableUnit(desc);
- }
+ for (InstallableUnitDescription desc : units)
+ result[i++] = MetadataFactory.createInstallableUnit(desc);
return result;
}
@@ -128,9 +138,9 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
private Version version;
private boolean singleton;
- private List units;
+ private List<InstallableUnitDescription> units;
- public InstallableUnitHandler(AbstractHandler parentHandler, Attributes attributes, List units) {
+ public InstallableUnitHandler(AbstractHandler parentHandler, Attributes attributes, List<InstallableUnitDescription> units) {
super(parentHandler, INSTALLABLE_UNIT_ELEMENT);
String[] values = parseAttributes(attributes, REQUIRED_IU_ATTRIBUTES, OPTIONAL_IU_ATTRIBUTES);
this.units = units;
@@ -248,7 +258,7 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
if (isValidXML()) {
if (requirementChangesHandler != null) {
currentUnit = new MetadataFactory.InstallableUnitPatchDescription();
- ((InstallableUnitPatchDescription) currentUnit).setRequirementChanges((IRequirementChange[]) requirementChangesHandler.getRequirementChanges().toArray(new IRequirementChange[requirementChangesHandler.getRequirementChanges().size()]));
+ ((InstallableUnitPatchDescription) currentUnit).setRequirementChanges(requirementChangesHandler.getRequirementChanges().toArray(new IRequirementChange[requirementChangesHandler.getRequirementChanges().size()]));
if (applicabilityScopeHandler != null)
((InstallableUnitPatchDescription) currentUnit).setApplicabilityScope(applicabilityScopeHandler.getScope());
if (lifeCycleHandler != null)
@@ -265,15 +275,15 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
OrderedProperties properties = (propertiesHandler == null ? new OrderedProperties(0) : propertiesHandler.getProperties());
String updateFrom = null;
VersionRange updateRange = null;
- for (Enumeration e = properties.keys(); e.hasMoreElements();) {
- String key = (String) e.nextElement();
- String value = properties.getProperty(key);
+ for (Entry<String, String> e : properties.entrySet()) {
+ String key = e.getKey();
+ String value = e.getValue();
//Backward compatibility
- if (key.equals("equinox.p2.update.from")) {
+ if (key.equals("equinox.p2.update.from")) { //$NON-NLS-1$
updateFrom = value;
continue;
}
- if (key.equals("equinox.p2.update.range")) {
+ if (key.equals("equinox.p2.update.range")) { //$NON-NLS-1$
updateRange = new VersionRange(value);
continue;
}
@@ -286,8 +296,7 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
//End of backward compatibility
if (licensesHandler != null) {
- ILicense license = licensesHandler.getLicense();
- currentUnit.setLicense(license);
+ currentUnit.setLicenses(licensesHandler.getLicenses());
}
if (copyrightHandler != null) {
@@ -297,9 +306,9 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
IProvidedCapability[] providedCapabilities = (providedCapabilitiesHandler == null ? new IProvidedCapability[0] : providedCapabilitiesHandler.getProvidedCapabilities());
currentUnit.setCapabilities(providedCapabilities);
- IRequiredCapability[] requiredCapabilities = (requiredCapabilitiesHandler == null ? new IRequiredCapability[0] : requiredCapabilitiesHandler.getRequiredCapabilities());
+ IRequirement[] requiredCapabilities = (requiredCapabilitiesHandler == null ? new IRequirement[0] : requiredCapabilitiesHandler.getRequiredCapabilities());
currentUnit.setRequiredCapabilities(requiredCapabilities);
- IRequiredCapability[] metaRequiredCapabilities = (metaRequiredCapabilitiesHandler == null ? new IRequiredCapability[0] : metaRequiredCapabilitiesHandler.getMetaRequiredCapabilities());
+ IRequirement[] metaRequiredCapabilities = (metaRequiredCapabilitiesHandler == null ? new IRequirement[0] : metaRequiredCapabilitiesHandler.getMetaRequiredCapabilities());
currentUnit.setMetaRequiredCapabilities(metaRequiredCapabilities);
if (filterHandler != null) {
currentUnit.setFilter(filterHandler.getText());
@@ -321,13 +330,12 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
}
- protected class ApplicabilityScopesHandler extends AbstractHandler {
- private List scopes;
+ protected class ApplicabilityScopesHandler extends AbstractMetadataHandler {
+ private List<IRequirement[]> scopes;
public ApplicabilityScopesHandler(AbstractHandler parentHandler, Attributes attributes) {
super(parentHandler, APPLICABILITY_SCOPE);
- String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE);
- scopes = (size != null ? new ArrayList(new Integer(size).intValue()) : new ArrayList(4));
+ scopes = new ArrayList<IRequirement[]>(getOptionalSize(attributes, 4));
}
public void startElement(String name, Attributes attributes) {
@@ -338,16 +346,16 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
}
- public IRequiredCapability[][] getScope() {
- return (IRequiredCapability[][]) scopes.toArray(new IRequiredCapability[scopes.size()][]);
+ public IRequirement[][] getScope() {
+ return scopes.toArray(new IRequirement[scopes.size()][]);
}
}
protected class ApplicabilityScopeHandler extends AbstractHandler {
private RequiredCapabilitiesHandler children;
- private List scopes;
+ private List<IRequirement[]> scopes;
- public ApplicabilityScopeHandler(AbstractHandler parentHandler, Attributes attributes, List scopes) {
+ public ApplicabilityScopeHandler(AbstractHandler parentHandler, Attributes attributes, List<IRequirement[]> scopes) {
super(parentHandler, APPLY_ON);
this.scopes = scopes;
}
@@ -367,13 +375,12 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
}
- protected class RequirementsChangeHandler extends AbstractHandler {
- private List requirementChanges;
+ protected class RequirementsChangeHandler extends AbstractMetadataHandler {
+ private List<IRequirementChange> requirementChanges;
public RequirementsChangeHandler(InstallableUnitHandler parentHandler, Attributes attributes) {
super(parentHandler, REQUIREMENT_CHANGES);
- String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE);
- requirementChanges = (size != null ? new ArrayList(new Integer(size).intValue()) : new ArrayList(4));
+ requirementChanges = new ArrayList<IRequirementChange>(getOptionalSize(attributes, 4));
}
public void startElement(String name, Attributes attributes) {
@@ -384,20 +391,20 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
}
- public List getRequirementChanges() {
+ public List<IRequirementChange> getRequirementChanges() {
return requirementChanges;
}
}
protected class RequirementChangeHandler extends AbstractHandler {
- private List from;
- private List to;
- private List requirementChanges;
+ private List<IRequirement> from;
+ private List<IRequirement> to;
+ private List<IRequirementChange> requirementChanges;
- public RequirementChangeHandler(AbstractHandler parentHandler, Attributes attributes, List requirementChanges) {
+ public RequirementChangeHandler(AbstractHandler parentHandler, Attributes attributes, List<IRequirementChange> requirementChanges) {
super(parentHandler, REQUIREMENT_CHANGE);
- from = new ArrayList(1);
- to = new ArrayList(1);
+ from = new ArrayList<IRequirement>(1);
+ to = new ArrayList<IRequirement>(1);
this.requirementChanges = requirementChanges;
}
@@ -415,14 +422,14 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
protected void finished() {
- requirementChanges.add(MetadataFactory.createRequirementChange(from.size() == 0 ? null : (IRequiredCapability) from.get(0), to.size() == 0 ? null : (IRequiredCapability) to.get(0)));
+ requirementChanges.add(MetadataFactory.createRequirementChange(from.size() == 0 ? null : (IRequirement) from.get(0), to.size() == 0 ? null : (IRequirement) to.get(0)));
}
}
protected class RequirementChangeEltHandler extends AbstractHandler {
- private List requirement;
+ private List<IRequirement> requirement;
- public RequirementChangeEltHandler(AbstractHandler parentHandler, String parentId, Attributes attributes, List from) {
+ public RequirementChangeEltHandler(AbstractHandler parentHandler, String parentId, Attributes attributes, List<IRequirement> from) {
super(parentHandler, parentId);
requirement = from;
}
@@ -438,17 +445,17 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
protected class LifeCycleHandler extends AbstractHandler {
- private List lifeCycleRequirement;
+ private List<IRequirement> lifeCycleRequirement;
public LifeCycleHandler(AbstractHandler parentHandler, Attributes attributes) {
super(parentHandler, LIFECYCLE);
- lifeCycleRequirement = new ArrayList(1);
+ lifeCycleRequirement = new ArrayList<IRequirement>(1);
}
- public IRequiredCapability getLifeCycleRequirement() {
+ public IRequirement getLifeCycleRequirement() {
if (lifeCycleRequirement.size() == 0)
return null;
- return (IRequiredCapability) lifeCycleRequirement.get(0);
+ return lifeCycleRequirement.get(0);
}
public void startElement(String name, Attributes attributes) {
@@ -460,17 +467,16 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
}
- protected class ProvidedCapabilitiesHandler extends AbstractHandler {
- private List providedCapabilities;
+ protected class ProvidedCapabilitiesHandler extends AbstractMetadataHandler {
+ private List<IProvidedCapability> providedCapabilities;
public ProvidedCapabilitiesHandler(AbstractHandler parentHandler, Attributes attributes) {
super(parentHandler, PROVIDED_CAPABILITIES_ELEMENT);
- String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE);
- providedCapabilities = (size != null ? new ArrayList(new Integer(size).intValue()) : new ArrayList(4));
+ providedCapabilities = new ArrayList<IProvidedCapability>(getOptionalSize(attributes, 4));
}
public IProvidedCapability[] getProvidedCapabilities() {
- return (IProvidedCapability[]) providedCapabilities.toArray(new IProvidedCapability[providedCapabilities.size()]);
+ return providedCapabilities.toArray(new IProvidedCapability[providedCapabilities.size()]);
}
public void startElement(String name, Attributes attributes) {
@@ -484,7 +490,7 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
protected class ProvidedCapabilityHandler extends AbstractHandler {
- public ProvidedCapabilityHandler(AbstractHandler parentHandler, Attributes attributes, List capabilities) {
+ public ProvidedCapabilityHandler(AbstractHandler parentHandler, Attributes attributes, List<IProvidedCapability> capabilities) {
super(parentHandler, PROVIDED_CAPABILITY_ELEMENT);
String[] values = parseRequiredAttributes(attributes, REQUIRED_PROVIDED_CAPABILITY_ATTRIBUTES);
Version version = checkVersion(PROVIDED_CAPABILITY_ELEMENT, VERSION_ATTRIBUTE, values[2]);
@@ -496,17 +502,16 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
}
- protected class HostRequiredCapabilitiesHandler extends AbstractHandler {
- private List requiredCapabilities;
+ protected class HostRequiredCapabilitiesHandler extends AbstractMetadataHandler {
+ private List<IRequirement> requiredCapabilities;
public HostRequiredCapabilitiesHandler(AbstractHandler parentHandler, Attributes attributes) {
super(parentHandler, HOST_REQUIRED_CAPABILITIES_ELEMENT);
- String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE);
- requiredCapabilities = (size != null ? new ArrayList(new Integer(size).intValue()) : new ArrayList(4));
+ requiredCapabilities = new ArrayList<IRequirement>(getOptionalSize(attributes, 4));
}
- public IRequiredCapability[] getHostRequiredCapabilities() {
- return (IRequiredCapability[]) requiredCapabilities.toArray(new IRequiredCapability[requiredCapabilities.size()]);
+ public IRequirement[] getHostRequiredCapabilities() {
+ return requiredCapabilities.toArray(new IRequirement[requiredCapabilities.size()]);
}
public void startElement(String name, Attributes attributes) {
@@ -518,17 +523,16 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
}
- protected class MetaRequiredCapabilitiesHandler extends AbstractHandler {
- private List requiredCapabilities;
+ protected class MetaRequiredCapabilitiesHandler extends AbstractMetadataHandler {
+ private List<IRequirement> requiredCapabilities;
public MetaRequiredCapabilitiesHandler(AbstractHandler parentHandler, Attributes attributes) {
super(parentHandler, META_REQUIRED_CAPABILITIES_ELEMENT);
- String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE);
- requiredCapabilities = (size != null ? new ArrayList(new Integer(size).intValue()) : new ArrayList(4));
+ requiredCapabilities = new ArrayList<IRequirement>(getOptionalSize(attributes, 4));
}
- public IRequiredCapability[] getMetaRequiredCapabilities() {
- return (IRequiredCapability[]) requiredCapabilities.toArray(new IRequiredCapability[requiredCapabilities.size()]);
+ public IRequirement[] getMetaRequiredCapabilities() {
+ return requiredCapabilities.toArray(new IRequirement[requiredCapabilities.size()]);
}
public void startElement(String name, Attributes attributes) {
@@ -540,17 +544,16 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
}
- protected class RequiredCapabilitiesHandler extends AbstractHandler {
- private List requiredCapabilities;
+ protected class RequiredCapabilitiesHandler extends AbstractMetadataHandler {
+ private List<IRequirement> requiredCapabilities;
public RequiredCapabilitiesHandler(AbstractHandler parentHandler, Attributes attributes) {
super(parentHandler, REQUIRED_CAPABILITIES_ELEMENT);
- String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE);
- requiredCapabilities = (size != null ? new ArrayList(new Integer(size).intValue()) : new ArrayList(4));
+ requiredCapabilities = new ArrayList<IRequirement>(getOptionalSize(attributes, 4));
}
- public IRequiredCapability[] getRequiredCapabilities() {
- return (IRequiredCapability[]) requiredCapabilities.toArray(new IRequiredCapability[requiredCapabilities.size()]);
+ public IRequirement[] getRequiredCapabilities() {
+ return requiredCapabilities.toArray(new IRequirement[requiredCapabilities.size()]);
}
public void startElement(String name, Attributes attributes) {
@@ -563,28 +566,34 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
protected class RequiredCapabilityHandler extends AbstractHandler {
+ private List<IRequirement> capabilities;
- private IRequiredCapability currentCapability = null;
+ private String namespace;
+ private String name;
+ private VersionRange range;
+ private int min;
+ private int max;
+ private boolean greedy;
private TextHandler filterHandler = null;
- private CapabilitySelectorsHandler selectorsHandler = null;
- public RequiredCapabilityHandler(AbstractHandler parentHandler, Attributes attributes, List capabilities) {
+ public RequiredCapabilityHandler(AbstractHandler parentHandler, Attributes attributes, List<IRequirement> capabilities) {
super(parentHandler, REQUIRED_CAPABILITY_ELEMENT);
+ this.capabilities = capabilities;
String[] values = parseAttributes(attributes, REQIURED_CAPABILITY_ATTRIBUTES, OPTIONAL_CAPABILITY_ATTRIBUTES);
- VersionRange range = checkVersionRange(REQUIRED_CAPABILITY_ELEMENT, VERSION_RANGE_ATTRIBUTE, values[2]);
+ namespace = values[0];
+ name = values[1];
+ range = checkVersionRange(REQUIRED_CAPABILITY_ELEMENT, VERSION_RANGE_ATTRIBUTE, values[2]);
boolean isOptional = checkBoolean(REQUIRED_CAPABILITY_ELEMENT, CAPABILITY_OPTIONAL_ATTRIBUTE, values[3], false).booleanValue();
+ min = isOptional ? 0 : 1;
boolean isMultiple = checkBoolean(REQUIRED_CAPABILITY_ELEMENT, CAPABILITY_MULTIPLE_ATTRIBUTE, values[4], false).booleanValue();
- boolean isGreedy = checkBoolean(REQUIRED_CAPABILITY_ELEMENT, CAPABILITY_GREED_ATTRIBUTE, values[5], true).booleanValue();
- currentCapability = MetadataFactory.createRequiredCapability(values[0], values[1], range, null, isOptional, isMultiple, isGreedy);
- capabilities.add(currentCapability);
+ max = isMultiple ? Integer.MAX_VALUE : 1;
+ greedy = checkBoolean(REQUIRED_CAPABILITY_ELEMENT, CAPABILITY_GREED_ATTRIBUTE, values[5], true).booleanValue();
}
public void startElement(String name, Attributes attributes) {
if (name.equals(CAPABILITY_FILTER_ELEMENT)) {
filterHandler = new TextHandler(this, CAPABILITY_FILTER_ELEMENT, attributes);
- } else if (name.equals(CAPABILITY_SELECTORS_ELEMENT)) {
- selectorsHandler = new CapabilitySelectorsHandler(this, attributes);
} else {
invalidElement(name, attributes);
}
@@ -592,30 +601,26 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
protected void finished() {
if (isValidXML()) {
- if (currentCapability != null) {
- if (filterHandler != null) {
- currentCapability.setFilter(filterHandler.getText());
- }
- if (selectorsHandler != null) {
- currentCapability.setSelectors(selectorsHandler.getSelectors());
- }
- }
+ Filter filter = null;
+ if (filterHandler != null)
+ filter = ExpressionUtil.parseLDAP(filterHandler.getText());
+ capabilities.add(MetadataFactory.createRequiredCapability(namespace, name, range, filter, min, max, greedy));
}
}
}
protected class ArtifactsHandler extends AbstractHandler {
- private List artifacts;
+ private List<IArtifactKey> artifacts;
public ArtifactsHandler(AbstractHandler parentHandler, Attributes attributes) {
super(parentHandler, ARTIFACT_KEYS_ELEMENT);
String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE);
- artifacts = (size != null ? new ArrayList(new Integer(size).intValue()) : new ArrayList(4));
+ artifacts = (size != null ? new ArrayList<IArtifactKey>(new Integer(size).intValue()) : new ArrayList<IArtifactKey>(4));
}
public IArtifactKey[] getArtifactKeys() {
- return (IArtifactKey[]) artifacts.toArray(new IArtifactKey[artifacts.size()]);
+ return artifacts.toArray(new IArtifactKey[artifacts.size()]);
}
public void startElement(String name, Attributes attributes) {
@@ -631,7 +636,7 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
private final String[] required = new String[] {CLASSIFIER_ATTRIBUTE, ID_ATTRIBUTE, VERSION_ATTRIBUTE};
- public ArtifactHandler(AbstractHandler parentHandler, Attributes attributes, List artifacts) {
+ public ArtifactHandler(AbstractHandler parentHandler, Attributes attributes, List<IArtifactKey> artifacts) {
super(parentHandler, ARTIFACT_KEY_ELEMENT);
String[] values = parseRequiredAttributes(attributes, required);
Version version = checkVersion(ARTIFACT_KEY_ELEMENT, VERSION_ATTRIBUTE, values[2]);
@@ -643,29 +648,6 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
}
}
- protected class CapabilitySelectorsHandler extends AbstractHandler {
-
- private List selectors;
-
- public CapabilitySelectorsHandler(AbstractHandler parentHandler, Attributes attributes) {
- super(parentHandler, CAPABILITY_SELECTORS_ELEMENT);
- String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE);
- selectors = (size != null ? new ArrayList(new Integer(size).intValue()) : new ArrayList(4));
- }
-
- public String[] getSelectors() {
- return (String[]) selectors.toArray(new String[selectors.size()]);
- }
-
- public void startElement(String name, Attributes attributes) {
- if (name.equals(CAPABILITY_SELECTOR_ELEMENT)) {
- new TextHandler(this, CAPABILITY_SELECTOR_ELEMENT, attributes, selectors);
- } else {
- invalidElement(name, attributes);
- }
- }
- }
-
protected class TouchpointTypeHandler extends AbstractHandler {
private final String[] required = new String[] {ID_ATTRIBUTE, VERSION_ATTRIBUTE};
@@ -692,18 +674,18 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
ITouchpointData touchpointData = null;
- List data = null;
+ List<TouchpointInstructionsHandler> data = null;
public TouchpointDataHandler(AbstractHandler parentHandler, Attributes attributes) {
super(parentHandler, TOUCHPOINT_DATA_ELEMENT);
String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE);
- data = (size != null ? new ArrayList(new Integer(size).intValue()) : new ArrayList(4));
+ data = (size != null ? new ArrayList<TouchpointInstructionsHandler>(new Integer(size).intValue()) : new ArrayList<TouchpointInstructionsHandler>(4));
}
public ITouchpointData[] getTouchpointData() {
ITouchpointData[] result = new ITouchpointData[data.size()];
for (int i = 0; i < result.length; i++)
- result[i] = ((TouchpointInstructionsHandler) data.get(i)).getTouchpointData();
+ result[i] = data.get(i).getTouchpointData();
return result;
}
@@ -718,12 +700,12 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
protected class TouchpointInstructionsHandler extends AbstractHandler {
- Map instructions = null;
+ Map<String, ITouchpointInstruction> instructions = null;
- public TouchpointInstructionsHandler(AbstractHandler parentHandler, Attributes attributes, List data) {
+ public TouchpointInstructionsHandler(AbstractHandler parentHandler, Attributes attributes, List<TouchpointInstructionsHandler> data) {
super(parentHandler, TOUCHPOINT_DATA_INSTRUCTIONS_ELEMENT);
String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE);
- instructions = (size != null ? new LinkedHashMap(new Integer(size).intValue()) : new LinkedHashMap(4));
+ instructions = (size != null ? new LinkedHashMap<String, ITouchpointInstruction>(new Integer(size).intValue()) : new LinkedHashMap<String, ITouchpointInstruction>(4));
}
public ITouchpointData getTouchpointData() {
@@ -744,11 +726,11 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
private final String[] required = new String[] {TOUCHPOINT_DATA_INSTRUCTION_KEY_ATTRIBUTE};
private final String[] optional = new String[] {TOUCHPOINT_DATA_INSTRUCTION_IMPORT_ATTRIBUTE};
- Map instructions = null;
+ Map<String, ITouchpointInstruction> instructions = null;
String key = null;
String qualifier = null;
- public TouchpointInstructionHandler(AbstractHandler parentHandler, Attributes attributes, Map instructions) {
+ public TouchpointInstructionHandler(AbstractHandler parentHandler, Attributes attributes, Map<String, ITouchpointInstruction> instructions) {
super(parentHandler, TOUCHPOINT_DATA_INSTRUCTION_ELEMENT);
String[] values = parseAttributes(attributes, required, optional);
key = values[0];
@@ -788,21 +770,22 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
* Handler for a list of licenses.
*/
protected class LicensesHandler extends AbstractHandler {
+
// Note this handler is set up to handle multiple license elements, but for now
// the API for IInstallableUnit only reflects one.
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=216911
- private List licenses;
+ private List<ILicense> licenses;
public LicensesHandler(ContentHandler parentHandler, Attributes attributes) {
super(parentHandler, LICENSES_ELEMENT);
String size = parseOptionalAttribute(attributes, COLLECTION_SIZE_ATTRIBUTE);
- licenses = (size != null ? new ArrayList(new Integer(size).intValue()) : new ArrayList(2));
+ licenses = (size != null ? new ArrayList<ILicense>(new Integer(size).intValue()) : new ArrayList<ILicense>(2));
}
- public ILicense getLicense() {
+ public ILicense[] getLicenses() {
if (licenses.size() == 0)
- return null;
- return (ILicense) licenses.get(0);
+ return NO_LICENSES;
+ return licenses.toArray(new ILicense[licenses.size()]);
}
public void startElement(String name, Attributes attributes) {
@@ -822,9 +805,9 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
URI location = null;
- private final List licenses;
+ private final List<ILicense> licenses;
- public LicenseHandler(AbstractHandler parentHandler, Attributes attributes, List licenses) {
+ public LicenseHandler(AbstractHandler parentHandler, Attributes attributes, List<ILicense> licenses) {
super(parentHandler, LICENSE_ELEMENT);
location = parseURIAttribute(attributes, false);
this.licenses = licenses;
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java
index 7879ab7b7..1a5801bb1 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java
@@ -14,13 +14,15 @@ package org.eclipse.equinox.internal.p2.metadata.repository.io;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
-import java.util.Iterator;
-import java.util.Map;
+import java.util.*;
+import java.util.Map.Entry;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.p2.metadata.repository.Activator;
import org.eclipse.equinox.internal.p2.persistence.XMLWriter;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.query.FragmentQuery;
public abstract class MetadataWriter extends XMLWriter implements XMLConstants {
@@ -34,13 +36,15 @@ public abstract class MetadataWriter extends XMLWriter implements XMLConstants {
* @param units An Iterator of {@link IInstallableUnit}.
* @param size The number of units to write
*/
- protected void writeInstallableUnits(Iterator units, int size) {
+ protected void writeInstallableUnits(Iterator<IInstallableUnit> units, int size) {
if (size == 0)
return;
start(INSTALLABLE_UNITS_ELEMENT);
+
+ // The size is a bummer. Is it really needed? It forces the use of a collect
attribute(COLLECTION_SIZE_ATTRIBUTE, size);
while (units.hasNext())
- writeInstallableUnit((IInstallableUnit) units.next());
+ writeInstallableUnit(units.next());
end(INSTALLABLE_UNITS_ELEMENT);
}
@@ -52,7 +56,7 @@ public abstract class MetadataWriter extends XMLWriter implements XMLConstants {
attribute(SINGLETON_ATTRIBUTE, iu.isSingleton(), true);
// attribute(FRAGMENT_ATTRIBUTE, iu.isFragment(), false);
- if (iu.isFragment() && iu instanceof IInstallableUnitFragment) {
+ if (FragmentQuery.isFragment(iu) && iu instanceof IInstallableUnitFragment) {
IInstallableUnitFragment fragment = (IInstallableUnitFragment) iu;
writeHostRequiredCapabilities(fragment.getHost());
}
@@ -69,18 +73,18 @@ public abstract class MetadataWriter extends XMLWriter implements XMLConstants {
writeMetaRequiredCapabilities(iu.getMetaRequiredCapabilities());
writeProvidedCapabilities(iu.getProvidedCapabilities());
writeRequiredCapabilities(iu.getRequiredCapabilities());
- writeTrimmedCdata(IU_FILTER_ELEMENT, iu.getFilter());
+ writeTrimmedCdata(IU_FILTER_ELEMENT, iu.getFilter() == null ? null : iu.getFilter().toString());
writeArtifactKeys(iu.getArtifacts());
writeTouchpointType(iu.getTouchpointType());
writeTouchpointData(iu.getTouchpointData());
- writeLicenses(iu.getLicense());
+ writeLicenses(iu.getLicenses());
writeCopyright(iu.getCopyright());
end(INSTALLABLE_UNIT_ELEMENT);
}
- protected void writeLifeCycle(IRequiredCapability capability) {
+ protected void writeLifeCycle(IRequirement capability) {
if (capability == null)
return;
start(LIFECYCLE);
@@ -88,7 +92,7 @@ public abstract class MetadataWriter extends XMLWriter implements XMLConstants {
end(LIFECYCLE);
}
- protected void writeHostRequiredCapabilities(IRequiredCapability[] capabilities) {
+ protected void writeHostRequiredCapabilities(IRequirement[] capabilities) {
if (capabilities != null && capabilities.length > 0) {
start(HOST_REQUIRED_CAPABILITIES_ELEMENT);
attribute(COLLECTION_SIZE_ATTRIBUTE, capabilities.length);
@@ -99,38 +103,38 @@ public abstract class MetadataWriter extends XMLWriter implements XMLConstants {
}
}
- protected void writeProvidedCapabilities(IProvidedCapability[] capabilities) {
- if (capabilities != null && capabilities.length > 0) {
+ protected void writeProvidedCapabilities(Collection<IProvidedCapability> capabilities) {
+ if (capabilities != null && capabilities.size() > 0) {
start(PROVIDED_CAPABILITIES_ELEMENT);
- attribute(COLLECTION_SIZE_ATTRIBUTE, capabilities.length);
- for (int i = 0; i < capabilities.length; i++) {
+ attribute(COLLECTION_SIZE_ATTRIBUTE, capabilities.size());
+ for (IProvidedCapability capability : capabilities) {
start(PROVIDED_CAPABILITY_ELEMENT);
- attribute(NAMESPACE_ATTRIBUTE, capabilities[i].getNamespace());
- attribute(NAME_ATTRIBUTE, capabilities[i].getName());
- attribute(VERSION_ATTRIBUTE, capabilities[i].getVersion());
+ attribute(NAMESPACE_ATTRIBUTE, capability.getNamespace());
+ attribute(NAME_ATTRIBUTE, capability.getName());
+ attribute(VERSION_ATTRIBUTE, capability.getVersion());
end(PROVIDED_CAPABILITY_ELEMENT);
}
end(PROVIDED_CAPABILITIES_ELEMENT);
}
}
- protected void writeMetaRequiredCapabilities(IRequiredCapability[] capabilities) {
- if (capabilities != null && capabilities.length > 0) {
+ protected void writeMetaRequiredCapabilities(Collection<IRequirement> metaRequirements) {
+ if (metaRequirements != null && metaRequirements.size() > 0) {
start(META_REQUIRED_CAPABILITIES_ELEMENT);
- attribute(COLLECTION_SIZE_ATTRIBUTE, capabilities.length);
- for (int i = 0; i < capabilities.length; i++) {
- writeRequiredCapability(capabilities[i]);
+ attribute(COLLECTION_SIZE_ATTRIBUTE, metaRequirements.size());
+ for (IRequirement req : metaRequirements) {
+ writeRequiredCapability(req);
}
end(META_REQUIRED_CAPABILITIES_ELEMENT);
}
}
- protected void writeRequiredCapabilities(IRequiredCapability[] capabilities) {
- if (capabilities != null && capabilities.length > 0) {
+ protected void writeRequiredCapabilities(Collection<IRequirement> requirements) {
+ if (requirements != null && requirements.size() > 0) {
start(REQUIRED_CAPABILITIES_ELEMENT);
- attribute(COLLECTION_SIZE_ATTRIBUTE, capabilities.length);
- for (int i = 0; i < capabilities.length; i++) {
- writeRequiredCapability(capabilities[i]);
+ attribute(COLLECTION_SIZE_ATTRIBUTE, requirements.size());
+ for (IRequirement req : requirements) {
+ writeRequiredCapability(req);
}
end(REQUIRED_CAPABILITIES_ELEMENT);
}
@@ -148,20 +152,20 @@ public abstract class MetadataWriter extends XMLWriter implements XMLConstants {
end(UPDATE_DESCRIPTOR_ELEMENT);
}
- protected void writeApplicabilityScope(IRequiredCapability[][] capabilities) {
+ protected void writeApplicabilityScope(IRequirement[][] capabilities) {
start(APPLICABILITY_SCOPE);
for (int i = 0; i < capabilities.length; i++) {
start(APPLY_ON);
- writeRequiredCapabilities(capabilities[i]);
+ writeRequiredCapabilities(Arrays.asList(capabilities[i]));
end(APPLY_ON);
}
end(APPLICABILITY_SCOPE);
}
- protected void writeRequirementsChange(IRequirementChange[] changes) {
+ protected void writeRequirementsChange(List<IRequirementChange> changes) {
start(REQUIREMENT_CHANGES);
- for (int i = 0; i < changes.length; i++) {
- writeRequirementChange(changes[i]);
+ for (int i = 0; i < changes.size(); i++) {
+ writeRequirementChange(changes.get(i));
}
end(REQUIREMENT_CHANGES);
}
@@ -181,38 +185,34 @@ public abstract class MetadataWriter extends XMLWriter implements XMLConstants {
end(REQUIREMENT_CHANGE);
}
- protected void writeRequiredCapability(IRequiredCapability capability) {
- start(REQUIRED_CAPABILITY_ELEMENT);
- attribute(NAMESPACE_ATTRIBUTE, capability.getNamespace());
- attribute(NAME_ATTRIBUTE, capability.getName());
- attribute(VERSION_RANGE_ATTRIBUTE, capability.getRange());
- attribute(CAPABILITY_OPTIONAL_ATTRIBUTE, capability.isOptional(), false);
- attribute(CAPABILITY_MULTIPLE_ATTRIBUTE, capability.isMultiple(), false);
- attribute(CAPABILITY_GREED_ATTRIBUTE, capability.isGreedy(), true);
- writeTrimmedCdata(CAPABILITY_FILTER_ELEMENT, capability.getFilter());
-
- String[] selectors = capability.getSelectors();
- if (selectors.length > 0) {
- start(CAPABILITY_SELECTORS_ELEMENT);
- attribute(COLLECTION_SIZE_ATTRIBUTE, selectors.length);
- for (int j = 0; j < selectors.length; j++) {
- writeTrimmedCdata(CAPABILITY_SELECTOR_ELEMENT, selectors[j]);
- }
- end(CAPABILITY_SELECTORS_ELEMENT);
+ protected void writeRequiredCapability(IRequirement requirement) {
+ if (requirement instanceof IRequiredCapability) {
+ IRequiredCapability reqCapability = (IRequiredCapability) requirement;
+ start(REQUIRED_CAPABILITY_ELEMENT);
+ attribute(NAMESPACE_ATTRIBUTE, reqCapability.getNamespace());
+ attribute(NAME_ATTRIBUTE, reqCapability.getName());
+ attribute(VERSION_RANGE_ATTRIBUTE, reqCapability.getRange());
+ attribute(CAPABILITY_OPTIONAL_ATTRIBUTE, requirement.getMin() == 0, false);
+ attribute(CAPABILITY_MULTIPLE_ATTRIBUTE, requirement.getMax() > 1, false);
+ attribute(CAPABILITY_GREED_ATTRIBUTE, requirement.isGreedy(), true);
+ if (requirement.getFilter() != null)
+ writeTrimmedCdata(CAPABILITY_FILTER_ELEMENT, requirement.getFilter().toString());
+ end(REQUIRED_CAPABILITY_ELEMENT);
+ } else {
+ throw new IllegalStateException();
}
- end(REQUIRED_CAPABILITY_ELEMENT);
}
- protected void writeArtifactKeys(IArtifactKey[] artifactKeys) {
- if (artifactKeys != null && artifactKeys.length > 0) {
+ protected void writeArtifactKeys(Collection<IArtifactKey> artifactKeys) {
+ if (artifactKeys != null && artifactKeys.size() > 0) {
start(ARTIFACT_KEYS_ELEMENT);
- attribute(COLLECTION_SIZE_ATTRIBUTE, artifactKeys.length);
- for (int i = 0; i < artifactKeys.length; i++) {
+ attribute(COLLECTION_SIZE_ATTRIBUTE, artifactKeys.size());
+ for (IArtifactKey artifactKey : artifactKeys) {
start(ARTIFACT_KEY_ELEMENT);
- attribute(ARTIFACT_KEY_CLASSIFIER_ATTRIBUTE, artifactKeys[i].getClassifier());
- attribute(ID_ATTRIBUTE, artifactKeys[i].getId());
- attribute(VERSION_ATTRIBUTE, artifactKeys[i].getVersion());
+ attribute(ARTIFACT_KEY_CLASSIFIER_ATTRIBUTE, artifactKey.getClassifier());
+ attribute(ID_ATTRIBUTE, artifactKey.getId());
+ attribute(VERSION_ATTRIBUTE, artifactKey.getVersion());
end(ARTIFACT_KEY_ELEMENT);
}
end(ARTIFACT_KEYS_ELEMENT);
@@ -226,21 +226,20 @@ public abstract class MetadataWriter extends XMLWriter implements XMLConstants {
end(TOUCHPOINT_TYPE_ELEMENT);
}
- protected void writeTouchpointData(ITouchpointData[] touchpointData) {
- if (touchpointData != null && touchpointData.length > 0) {
+ protected void writeTouchpointData(List<ITouchpointData> touchpointData) {
+ if (touchpointData != null && touchpointData.size() > 0) {
start(TOUCHPOINT_DATA_ELEMENT);
- attribute(COLLECTION_SIZE_ATTRIBUTE, touchpointData.length);
- for (int i = 0; i < touchpointData.length; i++) {
- ITouchpointData nextData = touchpointData[i];
- Map instructions = nextData.getInstructions();
+ attribute(COLLECTION_SIZE_ATTRIBUTE, touchpointData.size());
+ for (int i = 0; i < touchpointData.size(); i++) {
+ ITouchpointData nextData = touchpointData.get(i);
+ Map<String, ITouchpointInstruction> instructions = nextData.getInstructions();
if (instructions.size() > 0) {
start(TOUCHPOINT_DATA_INSTRUCTIONS_ELEMENT);
attribute(COLLECTION_SIZE_ATTRIBUTE, instructions.size());
- for (Iterator iter = instructions.entrySet().iterator(); iter.hasNext();) {
- Map.Entry entry = (Map.Entry) iter.next();
+ for (Entry<String, ITouchpointInstruction> entry : instructions.entrySet()) {
start(TOUCHPOINT_DATA_INSTRUCTION_ELEMENT);
attribute(TOUCHPOINT_DATA_INSTRUCTION_KEY_ATTRIBUTE, entry.getKey());
- ITouchpointInstruction instruction = (ITouchpointInstruction) entry.getValue();
+ ITouchpointInstruction instruction = entry.getValue();
if (instruction.getImportAttribute() != null)
attribute(TOUCHPOINT_DATA_INSTRUCTION_IMPORT_ATTRIBUTE, instruction.getImportAttribute());
cdata(instruction.getBody(), true);
@@ -262,27 +261,31 @@ public abstract class MetadataWriter extends XMLWriter implements XMLConstants {
}
}
- private void writeLicenses(ILicense license) {
- if (license != null) {
+ private void writeLicenses(Collection<ILicense> licenses) {
+ if (licenses != null && licenses.size() > 0) {
// In the future there may be more than one license, so we write this
// as a collection of one.
// See bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=216911
start(LICENSES_ELEMENT);
- attribute(COLLECTION_SIZE_ATTRIBUTE, 1);
- start(LICENSE_ELEMENT);
- if (license.getLocation() != null) {
- attribute(URI_ATTRIBUTE, license.getLocation().toString());
+ attribute(COLLECTION_SIZE_ATTRIBUTE, licenses.size());
+ for (ILicense license : licenses) {
+ if (license == null)
+ continue;
+ start(LICENSE_ELEMENT);
+ if (license.getLocation() != null) {
+ attribute(URI_ATTRIBUTE, license.getLocation().toString());
- try {
- // we write the URL attribute for backwards compatibility with 3.4.x
- // this attribute should be removed if we make a breaking format change.
- attribute(URL_ATTRIBUTE, URIUtil.toURL(license.getLocation()).toExternalForm());
- } catch (MalformedURLException e) {
- attribute(URL_ATTRIBUTE, license.getLocation().toString());
+ try {
+ // we write the URL attribute for backwards compatibility with 3.4.x
+ // this attribute should be removed if we make a breaking format change.
+ attribute(URL_ATTRIBUTE, URIUtil.toURL(license.getLocation()).toExternalForm());
+ } catch (MalformedURLException e) {
+ attribute(URL_ATTRIBUTE, license.getLocation().toString());
+ }
}
+ cdata(license.getBody(), true);
+ end(LICENSE_ELEMENT);
}
- cdata(license.getBody(), true);
- end(LICENSE_ELEMENT);
end(LICENSES_ELEMENT);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/XMLConstants.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/XMLConstants.java
index 337470ed3..49c113f90 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/XMLConstants.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/XMLConstants.java
@@ -10,16 +10,16 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository.io;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
public interface XMLConstants extends org.eclipse.equinox.internal.p2.persistence.XMLConstants {
// Constants defining the structure of the XML for metadata objects
// A format version number for metadata XML.
- public static final Version CURRENT_VERSION = new Version(0, 0, 1);
- public static final VersionRange XML_TOLERANCE = new VersionRange(CURRENT_VERSION, true, new Version(2, 0, 0), false);
+ public static final Version CURRENT_VERSION = Version.createOSGi(0, 0, 1);
+ public static final VersionRange XML_TOLERANCE = new VersionRange(CURRENT_VERSION, true, Version.createOSGi(2, 0, 0), false);
// Constants for processing Instructions
public static final String PI_METADATA_TARGET = "metadata"; //$NON-NLS-1$
@@ -64,8 +64,6 @@ public interface XMLConstants extends org.eclipse.equinox.internal.p2.persistenc
// Constants for sub-elements of a required capability element
public static final String CAPABILITY_FILTER_ELEMENT = "filter"; //$NON-NLS-1$
- public static final String CAPABILITY_SELECTORS_ELEMENT = "selectors"; //$NON-NLS-1$
- public static final String CAPABILITY_SELECTOR_ELEMENT = "selector"; //$NON-NLS-1$
// Constants for attributes of a required capability element
public static final String CAPABILITY_OPTIONAL_ATTRIBUTE = "optional"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/p2/metadata/repository/IMetadataRepository.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/p2/metadata/repository/IMetadataRepository.java
deleted file mode 100644
index 34a057d69..000000000
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/p2/metadata/repository/IMetadataRepository.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.provisional.p2.metadata.repository;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.IQueryable;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Query;
-
-import java.net.URI;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
-import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.AbstractMetadataRepository;
-
-/**
- * A metadata repository stores information about a set of installable units
- * <p>
- * This interface is not intended to be implemented by clients. Metadata repository
- * implementations must subclass {@link AbstractMetadataRepository} rather than
- * implementing this interface directly.
- * </p>
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface IMetadataRepository extends IRepository, IQueryable {
-
- /**
- * Add the given installable units to this repository
- * @param installableUnits the installable units to add
- */
- public void addInstallableUnits(IInstallableUnit[] installableUnits);
-
- /**
- * Adds a reference to another repository to this repository. When a repository
- * is loaded by {@link IMetadataRepositoryManager}, its references
- * are automatically added to the repository manager's set of known repositories.
- * <p>
- * Note that this method does not add the <b>contents</b> of the given
- * repository to this repository, but merely adds the location of another
- * repository to the metadata of this repository.
- * <p>
- * The {@link IRepository#ENABLED} option flag controls whether the
- * referenced repository should be marked as enabled when added to the repository
- * manager. If this flag is set, the repository will be marked as enabled when
- * added to the repository manager. If this flag is missing, the repository will
- * be marked as disabled.
- *
- * @param location the location of the repository to add
- * @param nickname The nickname of the repository, or <code>null</code>
- * @param type the repository type (currently either {@link IRepository#TYPE_METADATA}
- * or {@link IRepository#TYPE_ARTIFACT}).
- * @param options bit-wise or of option constants (currently either
- * {@link IRepository#ENABLED} or {@link IRepository#NONE}).
- * @see IMetadataRepositoryManager#setEnabled(URI, boolean)
- */
- public void addReference(URI location, String nickname, int type, int options);
-
- /**
- * Removes all installable units that match the given query from this repository.
- *
- * @param query the installable units to remove
- * @param monitor a progress monitor, or <code>null</code> if progress
- * reporting is not desired
- * @return <code>true</code> if any units were actually removed, and
- * <code>false</code> otherwise
- */
- public boolean removeInstallableUnits(Query query, IProgressMonitor monitor);
-
- /**
- * Remove all installable units from this repository.
- */
- public void removeAll();
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/p2/metadata/repository/IMetadataRepositoryManager.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/p2/metadata/repository/IMetadataRepositoryManager.java
deleted file mode 100644
index efe48c4ca..000000000
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/p2/metadata/repository/IMetadataRepositoryManager.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.provisional.p2.metadata.repository;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.IQueryable;
-
-import java.net.URI;
-import java.util.Map;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
-
-/**
- * A metadata repository manager is used to create, access, and manipulate
- * {@link IMetadataRepository} instances. See {@link IRepositoryManager}
- * for a general description of the characteristics of repository managers.
- *
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface IMetadataRepositoryManager extends IRepositoryManager, IQueryable {
- /**
- * The name used for obtaining a reference to the metadata repository manager service
- */
- public static final String SERVICE_NAME = IMetadataRepositoryManager.class.getName();
-
- /**
- * Repository type for a simple repository based on a URL or local file system location.
- */
- public static final String TYPE_SIMPLE_REPOSITORY = "org.eclipse.equinox.p2.metadata.repository.simpleRepository"; //$NON-NLS-1$
- public static final String TYPE_COMPOSITE_REPOSITORY = "org.eclipse.equinox.p2.metadata.repository.compositeRepository"; //$NON-NLS-1$
-
- /**
- * Creates and returns a new empty metadata repository of the given type at
- * the given location.
- * <p>
- * The resulting repository is added to the list of repositories tracked by
- * the repository manager. Clients must make a subsequent call to {@link #removeRepository(URI)}
- * if they do not want the repository manager to remember the repository for subsequent
- * load attempts.
- * </p>
- *
- * @param location the absolute 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 unknown.</li>
- * <li>There was an error writing to the given repository location.</li>
- * <li>A repository already exists at that location.</li>
- * </ul>
- */
- public IMetadataRepository createRepository(URI location, String name, String type, Map properties) throws ProvisionException;
-
- /**
- * Loads a repository corresponding to the given URL. If a repository has
- * previously been loaded at the given location, the same cached repository
- * may be returned.
- * <p>
- * The resulting repository is added to the list of repositories tracked by
- * the repository manager. Clients must make a subsequent call to {@link #removeRepository(URI)}
- * if they do not want the repository manager to remember the repository for subsequent
- * load attempts.
- * </p>
- *
- * @param location The absolute location of the repository to load
- * @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 IMetadataRepository loadRepository(URI location, IProgressMonitor monitor) throws ProvisionException;
-
- /**
- * Loads a repository corresponding to the given URL. If a repository has
- * previously been loaded at the given location, the same cached repository
- * may be returned.
- * <p>
- * The resulting repository is added to the list of repositories tracked by
- * the repository manager. Clients must make a subsequent call to {@link #removeRepository(URI)}
- * if they do not want the repository manager to remember the repository for subsequent
- * load attempts.
- * </p>
- * <p>
- * The flags passed in should be taken as a hint for the type of repository to load. If
- * the manager cannot load a repository that satisfies these hints, it can fail fast.
- * </p>
- * @param location The absolute location of the repository to load
- * @param flags - bit-wise or of flags to consider when loading the repository
- * (currently only {@link IRepositoryManager#REPOSITORY_HINT_MODIFIABLE} is supported)
- * @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>
- * @see IRepositoryManager#REPOSITORY_HINT_MODIFIABLE
- */
- public IMetadataRepository loadRepository(URI location, int flags, IProgressMonitor monitor) throws ProvisionException;
-
- /**
- * Refreshes the repository corresponding to the given URL. This method discards
- * any cached state held by the repository manager and reloads the repository
- * contents. The provided repository location must already be known to the repository
- * manager.
- *
- * @param location The absolute location of the repository to refresh
- * @param monitor a progress monitor, or <code>null</code> if progress
- * reporting is not desired
- * @return The refreshed metadata repository
- * @throws ProvisionException if the repository could not be refreshed. Reasons include:
- * <ul>
- * <li>The location is not known to the repository manager.</li>
- * <li>There is no existing repository at that location.</li>
- * <li>The repository at that location could not be read.</li>
- * </ul>
- */
- public IMetadataRepository refreshRepository(URI location, IProgressMonitor monitor) throws ProvisionException;
-
- /**
- * Validates a given URL and returns a status indicating whether a valid repository is likely
- * to be found at the given URL. Callers must assume that the validity of a
- * repository location cannot be completely determined until an attempt to load
- * the repository is made.
- *
- * @param location The absolute location of the repository to validate
- * @param monitor a progress monitor, or <code>null</code> if progress
- * reporting is not desired
- * @return A status indicating whether a valid repository is likely located at the
- * location. A status with severity <code>OK</code> indicates that the repository is
- * likely to be loadable, or that as much validation as could be done was successful.
- * Reasons for a non-OK status include:
- * <ul>
- * <li>The specified location is not a valid repository location.</li>
- * <li>There is no existing repository at that location.</li>
- * <li>The repository at that location could not be read.</li>
- * </ul>
- */
- public IStatus validateRepositoryLocation(URI location, IProgressMonitor monitor);
-}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/metadata/repository/AbstractMetadataRepository.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/metadata/repository/AbstractMetadataRepository.java
deleted file mode 100644
index 4a2652cba..000000000
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/metadata/repository/AbstractMetadataRepository.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Query;
-
-import org.eclipse.equinox.internal.provisional.spi.p2.repository.AbstractRepository;
-
-import java.net.URI;
-import java.util.Map;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-
-/**
- * The common base class for all metadata repositories.
- * <p>
- * Clients may subclass this class.
- * <p>
- */
-public abstract class AbstractMetadataRepository extends AbstractRepository implements IMetadataRepository {
-
- //TODO Consider removing from abstract class, this is currently an implementation detail of the simple metadata repo parser
- public static class RepositoryState {
- public String Name;
- public String Type;
- public Version Version;
- public String Provider;
- public String Description;
- public URI Location;
- public Map Properties;
- public IInstallableUnit[] Units;
- public RepositoryReference[] Repositories;
- }
-
- public AbstractMetadataRepository() {
- super("noName", "noType", "noVersion", null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- //TODO Consider removing from abstract class, this is currently an implementation detail of the simple metadata repo parser
- public abstract void initialize(RepositoryState state);
-
- protected AbstractMetadataRepository(String name, String type, String version, URI location, String description, String provider, Map properties) {
- super(name, type, version, location, description, provider, properties);
- }
-
- public void addInstallableUnits(IInstallableUnit[] installableUnit) {
- assertModifiable();
- }
-
- public void addReference(URI repositoryLocation, String nickname, int repositoryType, int options) {
- assertModifiable();
- }
-
- public void removeAll() {
- assertModifiable();
- }
-
- public boolean removeInstallableUnits(Query query, IProgressMonitor monitor) {
- assertModifiable();
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/metadata/repository/MetadataRepositoryFactory.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/metadata/repository/MetadataRepositoryFactory.java
deleted file mode 100644
index cfd2114d4..000000000
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/metadata/repository/MetadataRepositoryFactory.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository;
-
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
-
-import java.net.URI;
-import java.util.Map;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.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.
- */
-public abstract class MetadataRepositoryFactory {
-
- /**
- * 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 properties) throws ProvisionException;
-
- /**
- * 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;
-
- /**
- * Validates a candidate repository URL and returns a status indicating the
- * likelihood of a valid repository being located at the location. Implementors
- * should make all attempts to validate the URL that can be made without
- * actually loading the repository. The computation for this method must be
- * significantly faster than loading the repository. Early detectable error
- * conditions, such as the non-existence of the location, or an inability to read
- * the location, should be determined in this method.
- *
- * @param location The location of the repository to validate
- * @param monitor a progress monitor, or <code>null</code> if progress
- * reporting is not desired
- * @return A status indicating whether a valid repository is likely located at the
- * location. A status with severity <code>OK</code> indicates that the repository is
- * likely to be loadable, or that as much validation as could be done was successful.
- * Reasons for a non-OK status include:
- * <ul>
- * <li>The specified location is not a valid repository location.</li>
- * <li>There is no existing repository at that location.</li>
- * <li>The repository at that location could not be read.</li>
- * </ul>
- */
- public abstract IStatus validate(URI location, IProgressMonitor monitor);
-}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/metadata/repository/RepositoryReference.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/metadata/repository/RepositoryReference.java
deleted file mode 100644
index 9a7e2d842..000000000
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/provisional/spi/p2/metadata/repository/RepositoryReference.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository;
-
-import java.net.URI;
-
-/**
- * Serialization helper class for repository references.
- */
-public class RepositoryReference {
- public URI Location;
- public int Type;
- public int Options;
- public String Nickname;
-
- public RepositoryReference(URI location, String nickname, int type, int options) {
- this.Location = location;
- this.Type = type;
- this.Options = options;
- this.Nickname = nickname;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- RepositoryReference other = (RepositoryReference) obj;
- if (Location == null) {
- if (other.Location != null)
- return false;
- } else if (!Location.equals(other.Location))
- return false;
- if (Type != other.Type)
- return false;
- return true;
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((Location == null) ? 0 : Location.hashCode());
- result = prime * result + Type;
- return result;
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/AddChildTask.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/AddChildTask.java
index a19d18a60..33b151088 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/AddChildTask.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/AddChildTask.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository.ant;
+import org.eclipse.equinox.p2.core.ProvisionException;
+
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.tools.ant.BuildException;
@@ -18,8 +20,7 @@ import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.metadata.repository.Activator;
import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
/**
* Ant task for adding a child repository to a composite metadata repository.
@@ -34,7 +35,7 @@ public class AddChildTask extends Task {
*/
public void execute() {
validate();
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
if (manager == null)
throw new BuildException("Unable to aquire metadata repository manager service.");
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/CreateCompositeMetadataRepositoryTask.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/CreateCompositeMetadataRepositoryTask.java
index b6558259f..a1f80732a 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/CreateCompositeMetadataRepositoryTask.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/CreateCompositeMetadataRepositoryTask.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository.ant;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
+import org.eclipse.equinox.p2.core.ProvisionException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -22,9 +22,9 @@ import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.metadata.repository.Activator;
import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
/**
* Ant task for creating a new composite metadata repository.
@@ -35,13 +35,13 @@ public class CreateCompositeMetadataRepositoryTask extends Task {
String name = "Composite Metadata Repository";
boolean compressed = true; // compress by default
boolean failOnExists = false; // should we fail if one already exists?
- Map properties = new HashMap();
+ Map<String, String> properties = new HashMap<String, String>();
/* (non-Javadoc)
* @see org.apache.tools.ant.Task#execute()
*/
public void execute() {
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
if (manager == null)
throw new BuildException("Unable to aquire metadata repository manager service.");
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/MirrorApplicationTask.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/MirrorApplicationTask.java
deleted file mode 100644
index 07ef39edf..000000000
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/MirrorApplicationTask.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.metadata.repository.ant;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.eclipse.equinox.app.IApplicationContext;
-import org.eclipse.equinox.internal.p2.metadata.mirror.MirrorApplication;
-import org.osgi.framework.Bundle;
-
-/**
- * Ant task for running the metadata mirror application.
- */
-public class MirrorApplicationTask extends Task {
-
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
- private static final String ARG_DESTINATION = "-destination"; //$NON-NLS-1$
- private static final String ARG_DESTINATION_NAME = "-destinationName"; //$NON-NLS-1$
- private static final String ARG_SOURCE = "-source"; //$NON-NLS-1$
- private static final String ARG_WRITE_MODE = "-writeMode"; //$NON-NLS-1$
- URL source;
- URL destination;
- String destinationName;
- String writeMode;
-
- //TODO add transitive and roots attributed when implemented.
-
- /*
- * Run the mirror application with the given arguments.
- */
- private void runMirrorApplication(final String[] args) throws Exception {
- new MirrorApplication().start(new IApplicationContext() {
-
- public void applicationRunning() {
- // nothing to do
- }
-
- public Map getArguments() {
- Map arguments = new HashMap();
- arguments.put(IApplicationContext.APPLICATION_ARGS, args);
- return arguments;
- }
-
- public String getBrandingApplication() {
- return null;
- }
-
- public Bundle getBrandingBundle() {
- return null;
- }
-
- public String getBrandingDescription() {
- return null;
- }
-
- public String getBrandingId() {
- return null;
- }
-
- public String getBrandingName() {
- return null;
- }
-
- public String getBrandingProperty(String key) {
- return null;
- }
- });
- }
-
- /* (non-Javadoc)
- * @see org.apache.tools.ant.Task#execute()
- */
- public void execute() {
- // create arguments
- String[] args = new String[] { //
- ARG_SOURCE, source.toExternalForm(), //
- ARG_DESTINATION, destination.toExternalForm(), //
- ARG_WRITE_MODE, writeMode == null ? EMPTY_STRING : writeMode, //
- destinationName == null ? EMPTY_STRING : ARG_DESTINATION_NAME, //
- destinationName == null ? EMPTY_STRING : destinationName};
-
- try {
- runMirrorApplication(args);
- } catch (Exception e) {
- throw new BuildException("Error occurred while running metadata mirror application.", e);
- }
- }
-
- /*
- * Set the source location.
- */
- public void setSource(String value) throws MalformedURLException {
- source = new URL(value);
- }
-
- /*
- * Set the destination location.
- */
- public void setDestination(String value) throws MalformedURLException {
- destination = new URL(value);
- }
-
- /*
- * Set the destination name.
- */
- public void setDestinationName(String value) {
- destinationName = value;
- }
-
- /*
- * Set the write mode for the application. (e.g. clean or append)
- */
- public void setWriteMode(String value) {
- writeMode = value;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveChildTask.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveChildTask.java
index 3e12f4716..23421e3bc 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveChildTask.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveChildTask.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository.ant;
+import org.eclipse.equinox.p2.core.ProvisionException;
+
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.tools.ant.BuildException;
@@ -18,8 +20,7 @@ import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.metadata.repository.Activator;
import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
/**
* Ant task to remove a specific child repository (or all the children repositories)
@@ -35,7 +36,7 @@ public class RemoveChildTask extends Task {
* @see org.apache.tools.ant.Task#execute()
*/
public void execute() {
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
if (manager == null)
throw new BuildException("Unable to aquire metadata repository manager service.");

Back to the top